I realize that this has been asked on here before, but I don't seem to have the same issue as the previous person as the solutions provided had no effect.
My error is a little different as well.
undefined method `bootstrap_form_for' for #<#<Class:0x007fd2b0c2dbe0>:0x007fd2b0c2c948>
The code that references the method:
<%= bootstrap_form_for(#blob) do |f| %>
<%= f.text_field :contentType %>
<%= f.text_field :data %>
<%= f.text_field :form_id %>
<%= f.submit "Create BLOB" %>
<% end %>
The method comes from this gem.
The gem is in the Gemfile, I have restarted the rails server a few times, and I've tried this with multiple models.
It seems like bundle install was automatically fetching version 3.0.0 of the Gem, but the GitHub lists 2.3.0 as the most recent version available.
Switching to 2.3.0 in my Gemfile fixed the issue.
Related
I'm trying to switch a site to use the nested_form gem in combination with formtastic, which I'm already using, but I'm getting a strange error. Everything works perfectly fine in development, and tests pass. This error only occurs in production.
Visiting the page where semantic_nested_form_for is used causes the following error:
ActionView::Template::Error (undefined method `semantic_nested_form_for' for #<#<Class:0x0000000524cca0>:0x00000004e46a70>):
1: <%= semantic_nested_form_for(#volume) do |f| %>
2: <%= f.inputs do %>
3: <%= f.input :number, :label => 'Volume #', :input_html => {:style => 'width:100px;', :autofocus => true}, :hint => raw('Choose the volume number.') %>
4: <% end %>
app/views/volumes/_form.html.erb:1:in `_app_views_volumes__form_html_erb__2632693694855646779_43838320'
app/views/volumes/new.html.erb:3:in `_app_views_volumes_new_html_erb___2327298489284463705_41053660'
The gem is in my Gemfile and seems to be installed correctly:
[~/application/current]$ bundle show nested_form
/home/deployer/application/shared/bundle/ruby/1.9.1/gems/nested_form-0.3.1
I can even successfully call the semantic_nested_form_for in the production console:
[~/application/current]$ rails c production
Loading production environment (Rails 3.2.12)
irb(main):001:0> helper.semantic_nested_form_for(Volume.new, url: '/volumes' do |f|
irb(main):002:2* f.inputs
irb(main):003:2> f.actions
irb(main):004:2> end
irb(main):005:1>
Additionally, semantic_form_for works fine by itself, but nested_form_for (without the semantic_ part) does NOT work, leading me to think this is related directly to nested_form.
I don't think the erb code is really relevant to this issue, but here it is anyway:
<%= semantic_nested_form_for(#volume) do |f| %>
<%= f.inputs do %>
<%= f.input :number, label: 'Volume #', input_html: {autofocus: true}, hint: 'Choose the volume number.' %>
<% end %>
<div id="issues_fields">
<%= f.semantic_fields_for :issues %>
<%= f.link_to_add 'Add an Issue', :issues %>
</div>
<%= f.actions do %>
<%= f.action :submit, label: 'Save' %>
<% end %>
<% end %>
Well I'm a little dumbfounded. Capistrano restarts unicorn when I deploy, and before I asked this question I had tried manually restarting nginx and unicorn just to rule that out. After I asked the question I rebooted the entire production server (which I hate doing) just to see, and now it's working fine.
If anyone can tell me a good reason why simply rebooting the unicorn process wasn't enough, I'll mark their answer as the accepted answer.
I am using carmen-rails 1.0.0.beta 3 and for this I have used the following code:
<%= form_for(contact, remote: true, html: {class: 'popup-form'}) do |f| %>
<%= f.label :country, t('country') %>
<%= f.country_select :country, include_blank: "Select" %>
<% end %>
This gives a result like this:
Aland Island,
Antartica,
Afghanisthan,
..........
But I want Afghanisthan to start the list in case of alphabetical order.
Can anyone give a solution to this sorting problem. It would be helpful.
Thanks.
They've fixed this sorting bug, but perhaps they've not repackaged the gem or something. Try specifying the Git URL in your gemfile and I think it will work for you.
gem 'carmen-rails', git: 'https://github.com/jim/carmen-rails.git'
I'm using the gem nested_form in a Rails 3.1 application. The problem is that when I click on the link generated by "link_to_add", it displays the partial twice, whereas it should display it just once. There you go some code:
Form:
<%= nested_form_for #product, :html => {:multipart => true} do |f| %>
<%= f.fields_for :safety_info_files %>
# adds a link for displaying the template
<%= f.link_to_add "Add file", :safety_info_files %>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
Template:
<div class="fields">
<%= f.link_to_remove "remove" %><br />
<%= f.label :doc, "File" %>
<%= f.file_field :doc %><br />
</div>
Did anybody else have the same problem?
EDIT:
Silly mistake, silly me. Sorry if I made some of you wasting time, the problem was that I was loading "nested_form.js" twice, so it called the function that appended the partial the same number of times.
Sorry again.
Silly mistake, silly me. Sorry if I made some of you wasting time, the problem was that I was loading "nested_form.js" twice, so it called the function that appended the partial the same number of times.
For those having this issue using rails 4 / turbolinks and not finding nested_form.js included twice, try removing turbolinks from application.js. Once I did this and bounced the server this issue was resolved.
Credit here: https://github.com/ryanb/nested_form/issues/307
I was facing same issue.
I had included nested_form.js in my application layout file.
And I haven't changed my app/assets/javascripts/application.js file, it is as it is, when it was created at time of creating rails application.
When I removed entry from my application layout, problem was solved.
I have been struggling with this one for days and can't seem to figure out what's wrong. I'm attempting to allow polymorphic file attachments to a model Item, which belongs to model Location. My routes are defined as:
resources :locations do
resources :items
post :sort
end
resources :items do
resources :assets #model for attachments
end
I followed a tutorial about doing exactly this with carrierwave and nested_form. After setting everything up, however, I get the following error when requesting the New action for the Item model: wrong number of arguments (4 for 3). It tells me the error is occurring at line 7 of this view:
<%= nested_form_for [#location, #item], :html => { :multipart => true } do |f| %>
<p>
<%= f.label :name %><br />
<%= f.text_field :name %>
</p>
<%= f.fields_for :assets do |a_form| %> ### LINE 7 ####
<p>
<%= a_form.label :file %><br />
<%= a_form.file_field :file %>
<%= a_form.hidden_field :file_cache %>
</p>
<%= a_form.link_to_remove "Remove this attachment" %>
<% end %>
<%= f.link_to_add "Add attachment", :assets %>
<p><%= f.submit %></p>
<% end %>
If I don't use the nested_form gem and start out the view with a normal form_for, I get no errors and am able to successfully attach a single file to the Item. I can try and proceed without the gem, but (as far as I understand) nested_form will automate some of the functionality like removing the files and generating ajax to add new attachments.
I was just wondering if anyone has run into this error or knows what mistake I'm making that's causing problems with nested_form? I understand what the error means, just not sure where/why the extra argument is being thrown in. I greatly appreciate any insight you can provide!
FYI my dev setup: rails (3.1.0, 3.0.10), nested_form (0.1.1), carrierwave (0.5.7)
In order to get nested_form working with rails 3.1, I had to pull the latest from github rather than using what's in the gem. In my Gemfile:
gem "nested_form", :git => "git://github.com/ryanb/nested_form.git"
Login
1 error prohibited this {{model}} from being saved
There were problems with the following fields:
{{attribute}} {{message}}
this is the view code
<h1>Login</h1>
<% form_for #user_session, :url => user_session_path do |f| %>
<%= f.error_messages %>
<%= f.label :login %><br />
<%= f.text_field :login %><br />
<br />
<%= f.label :password %><br />
<%= f.password_field :password %><br />
<br />
<%= f.check_box :remember_me %><%= f.label :remember_me %><br />
<br />
<%= f.submit "Login" %>
<% end %>
`
its odd and it shows up on in the time_ago_in_words method when the out put is in months
just kinda started doing this randomly, anybody seen this before?
Yes, it happens when the version of Ruby has been upgraded to a version that is not supported by your version of Rails. Older version of rails uses a syntax that is not supported by newer versions of Ruby.
To solve it, you should either upgrade Rails or downgrade Ruby.
Rails 2.3.9 should be sufficient.
http://weblog.rubyonrails.org/2010/9/4/ruby-on-rails-2-3-9-released
the i18n gem needs to correspond to the version of RUBY and RAILS that you're running ...
changelog for i18n.
http://blog.plataformatec.com.br/2010/02/rails-3-i18n-changes/
running
gem uninstall i18n
then
gem install i18n -v 0.4.0
should solve any issues you've got with rails 2.3.8 and the double curly bracket error messages
You can also run into this if you install the i18n gem. I had installed metrical, and one of its dependencies is the i18n gem. This caused the same error as above. Once I removed the gem, I started seeing the correct messages again.
cd <yourRailsProject>
gem install i18n -v 0.4.0 -i vendor/ -V
to install the i18n gem into the vendor folder (-V for verbose output, just to see what's going on under the hood)