Questions tagged [actionview]

For questions about Action Views, HTML and Ruby templates used in Ruby on Rails

HTML and Ruby templates used in .

Action View is the View part of for , and is a part of the Ruby-On-Rails Action Pack.

490 questions
7
votes
3 answers

Passing block to label helper in rails3

I want to create label tag with some nested elements. I am using label helper and trying to pass inner html as block but generated HTML doesn't look as I expected. ERB: Span element <%= label("object", "method") do %> Inner…
mzaj
  • 85
  • 2
  • 5
7
votes
4 answers

Discrepancy when capturing Rails view block

I have an ERB view with two blocks: <%= test_h1 do %> <%= 'test1' %> <% end -%> <%= test_h2 do %> <%= 'test2' %> <% end -%> where test_h1 and test_h2 are similar helpers, but one is defined in a helper file, while another via helper_method in…
Alexander Azarov
  • 12,971
  • 2
  • 50
  • 54
7
votes
3 answers

Rails distance_of_time_in_words returns "en, about_x_hours"

I'm having a weird problem, hoping someone knows what the issue is... Using distance_of_time_in_words (and consequently time_ago_in_words) is not returning the actual time distance. Instead it is returning things like "en, about_x_hours" or "en,…
Steven Ou
  • 393
  • 2
  • 13
7
votes
4 answers

Rails: link_to with block and GET params?

How can I achieve query string and URL parameters in a link_to block declaration? Right now, I have this, which works: <%= link_to 'Edit', :edit, :type => 'book', :id => book %> The above works, and…
ground5hark
  • 4,464
  • 8
  • 30
  • 35
7
votes
2 answers

How do I delegate to a model's to_builder method from a JBuilder view?

Let's say I have a Person class and a Gang class class Person belongs_to :gang attr_accessible :name, :secret def to_builder Jbuilder.new do |app| person.id id person.name name end end end class Gang has_many :people …
Chris Aitchison
  • 4,656
  • 1
  • 27
  • 43
7
votes
5 answers

One controller, different views for normal users and admins

in my application, I have a "User" model. Each user can have multiple (email) addresses which are defined in the model "Address": Class User < ActiveRecord::Base has_many :addresses def is_authorized(op) # returns true or false end …
cite
  • 778
  • 5
  • 12
6
votes
5 answers

Rails validation and 'fieldWithErrors' wrapping select tags

Is it normal behaviour to not get the
wrapped arround select tags that have validation errors? I personally see no reason why the select tags should be treated differently than other form tags (input, textarea). I do…
andi
  • 14,322
  • 9
  • 47
  • 46
6
votes
4 answers

Rails 3 not loading HAML handler

I'm having some problems with Rails 3 and HAML in my application: for some reason Rails appears not to be loading the handler for dealing with haml files. Every action gives an error message similar to this one: Template is missing Missing template…
ldnunes
  • 178
  • 3
  • 14
6
votes
3 answers

ActionView::TemplateError (Missing template) In ruby on rails

I am running a RoR application (rails 2.3.8, ruby 1.8.7), the application runs fine on my local machine. but on production the logs show the following error: ActionView::TemplateError (Missing template folder/_file_name.erb in view path app/views)…
wael34218
  • 4,860
  • 8
  • 44
  • 62
6
votes
2 answers

Generating unique HTML ids in Rails when using a repeated partial that has form_for

I have a view on my current project which does something like the following(in haml): -@horses.each do |horse| = render :partial => 'main/votingbox', :locals => {:horse => horse} The in the _votingbox.html.haml file I have the…
cyberkni
  • 61
  • 1
  • 3
6
votes
1 answer

How do I use lookup_context to make this view as DRY as possible?

For starters, this is the view I am trying to replicate: This is the HTML from that layout (from the SAT portion anyway, you can extrapolate the rest): …
marcamillion
  • 32,933
  • 55
  • 189
  • 380
6
votes
2 answers

How to render HTML from a Rails instance variable?

I have an intstance variable I am passing to a view, @body. @body is a string with html in it. <%= @body %> renders the string, not the html. How do I render the html in the string? Possible? Thanks in advance!
Stirman
  • 1,574
  • 3
  • 11
  • 12
6
votes
6 answers

Android ActionBar custom action view tool-tip

I have an app that is using a SupportActionBar. I am usin a custom view for an action. The thing is, that default actions do display a tool-tip when i long press, but my custom action does not. So here is the default action (as you can see, there…
Arthur
  • 1,433
  • 1
  • 18
  • 35
6
votes
3 answers

automatically load a javascript function after loading page

I'm new to Rails and didn't really understand the asset pipeline by now… I want to let a views/product/product.js automatically fire after the views/product/index.html.erb was rendered for DRY reasons. Is there a place in the asset pipeline…
6
votes
4 answers

Accessing URL Helpers when Rendering Partials from Rails Models

I have to render some templates and send the HTML block to SendGrid for email substitution. So, unfortunately, I am doing some rendering in model like this: view = ActionView::Base.new(Rails.configuration.paths["app/views"].first) …