Questions tagged [actionviewhelper]

For questions about helper classes for the Ruby on Rails module Action View.

For questions about helper classes for the module .

86 questions
1
vote
1 answer

RoR: undefined method `url_for' for nil:NilClass

I have a standard Rails application. When a Tip is created, I would like to create a Message for each User who is interested in that Tip. This sounds simple right? It should be... So, we start with a Tip Observer: class TipObserver <…
ktec
  • 2,453
  • 3
  • 26
  • 32
1
vote
0 answers

switching between values with .each in a rails view

I remember seeing a rails method that was something like: <%= toggle(["hello", "i", "am"]) %> and if put in a .each like this: <% @something.each do |s| %> <%= toggle(["hello", "i", "am"]) %> <% end %> it should produce the following: hello i…
Philip7899
  • 4,599
  • 4
  • 55
  • 114
1
vote
0 answers

Yielding blocks in Rails ActionView

I am trying to build my Rails app following the Presenter design pattern. A part of my page includes a few divs nested inside an anchor tag, which works fine using regular html, but does not work when I try to render it using ActionView helpers. My…
azrosen92
  • 8,357
  • 4
  • 26
  • 45
1
vote
1 answer

rails actionview: How to "not show" attributes if receiving nil or something else

Is there an easy way to remove options attributes for the tag or content_tag helper? <%= content_tag :div, content, { class: 'content', style: styles_hash.map{|x| "#{x[0].underscore.dasherize}: #{x[1]}"}.join('; '), data: { hyperlink:…
index
  • 3,697
  • 7
  • 36
  • 55
1
vote
1 answer

Rails helper method to display email with sub mask asterisk

How to write like a helper method for email address to display with sub mask asterisk. If user email address is like "john.a@stackoverflow.com", But in view I want to display joh***@***.com <%= sub_masked_email("john.a@stackoverflow.com")…
prasannaboga
  • 1,004
  • 1
  • 14
  • 36
1
vote
1 answer

Rails 4.1.4 ActionView::Base Default Form Builder Doesn't Exist

Using Ruby 2.1.1 Rails 4.1.4 Hi, I've been banging my head on a really strange issue I'm seeing with FormHelper. I'm simply trying to build a form using form_for and I'm getting the cannot call new for nil class error when the view tries to render.…
1
vote
1 answer

Rails Action View Form Helper pass options hash to create element

Given a hash of properties for a text_field to be made in HAML: entry = {class: "form-control", disabled: true, id: :foobar} How can I do this: %dd!= f.send(:text_field, entry[:id], class: entry[:class], disabled: entry[:disabled]) But flexible?…
xxjjnn
  • 14,591
  • 19
  • 61
  • 94
1
vote
1 answer

Rails form helper: Override id of Rails hidden model id

According to the docs for Form Helper's form_for: The form_for method automatically includes the model id as a hidden field in the form. This is used to maintain the correlation between the form data and its associated model. Some ORM systems…
nickcoxdotme
  • 6,567
  • 9
  • 46
  • 72
1
vote
1 answer

Rails 2.1 content_tag in Helper

Does anyone know how to include content_tag in helpers? I tried including ActionView::Helpers::TagHelper.
Dan Grahn
  • 9,044
  • 4
  • 37
  • 74
1
vote
1 answer

How to change the output unit notation when using the number_to_human_size ActionView::Helper

I have been using the excellent number_to_human_size ActionView::Helper and I was wondering if there is any way to change the output unit notation: The default behavior is to output the units in Bytes, KB, MB, etc while I would like to see Bit, Kb,…
Cacofonix
  • 465
  • 11
  • 19
1
vote
1 answer

How to get the automatically generated ID for an actionview form helper 'number_field' input?

I'm trying to retrieve an ID that is being generated for an input via the number_field actionview form helper. I am updating some existing code which has the following input without a label: <%= item_form.number_field :quantity, :min => 0 %> When I…
Dawn
  • 941
  • 6
  • 11
1
vote
1 answer

Is there a way to override the AtomFeedBuilder updated_at value?

According to the documentation, an entry's updated value Defaults to the updated_at attribute on the record if one such exists. I'm trying to override the updated value, but instead I'm getting two updated fields in my RSS feed. If I set a different…
James Chevalier
  • 10,604
  • 5
  • 48
  • 74
0
votes
1 answer

Zend: how do I share common code between view and action helpers?

I need a boolean from a combination of some configuration and a call to an external webservice. The boolean is needed in the layout file of every view. It is also needed in a select few controllers. I have both an action and a view helper that get…
0
votes
1 answer

Is this the correct way of rendering a yield content_for?

<%= yield(:title_box) if content_for?(:title_box) %> Or is the if condition useless here?
0
votes
1 answer

How to fix error in rails 7 action view helper?

I'm getting this error ("wrong number of arguments (given 1, expected 0)") in the following helper. module PropertiesHelper def property_thumbnail img = property.photo.present? ? property.photo.thumb.url : "placeholder.png" …
Fuaad
  • 197
  • 15