1- I installed gem bootstrap_form
2- I wrote in application.css that line *= require bootstrap_form before the */
3- in my html.erb
<%= bootstrap_form_for(#guardian, :url => student_guardians_path(#student),
html: { class: 'form-horizontal' },
method: :post) do |f| %>
And I am getting the following error : undefined methodbootstrap_form_for' for #<#:0xb31a80c>`
I was getting the same error. Fixed it by replacing
gem 'bootstrap-form'
by
gem 'bootstrap_form'
in my gemfile
I too was getting this error until I realized that I didn't restart the rails server. When I restarted the server, the error disappeared.
I recently had this issue and my problem was that bundle install seemed to be pulling v3.0.0, yet the most recent version on GitHub is listed as 2.3.0. Changing the appropriate line in my Gemfile to:
gem 'bootstrap_form', '~> 2.3.0'
Fixed the issue.
This issue was solved by writing the form's code correctly as shown in #sunny1304's comment bootstrap_form_for([#student,#guardian]. So if none of the existing answers worked for you this might be a hint or something to guide you.
Thanks to other contributors as their answers helped other users who faced the issue like me.
Related
In my project with content_tag_for I had an error:
The content_tag_for method has been removed from Rails. To continue
using it, add the record_tag_helper gem to your Gemfile: gem
'record_tag_helper', '~> 1.0'
So, I added this gem to my Gemfile. $ bundle install returns:
Using record_tag_helper 1.0.0
I have restarted server, cleared Rails cache and so on, but I still have the same error, that content_tag_for method has been removed from Rails. I just have no more ideas why it doesn't work.
Share your ideas, please.
Looking at the Github page, the gem has not been updated in 2 years. Also the last update contains the message 'Prep for Rails 5'. I'm assuming that this gem isn't compatible with Rails 5.
I have added "require 'record_tag_helper'" to my application.rb file and now it works.
am using the country_state_select gem on simple_form,though my authentication is done using devise,i get this error each time i try to load
the page with the country_select option
"undefined method `countries_collection' for CountryStateSelect:Module"
my code is below
f.input :country, collection: CountryStateSelect.countries_collection
but it never loads,i keep getting that error message.
Try
gem 'country_state_select', '3.0.0'
in your Gemfile.
I got the same error you did, so I tried the latest version and it works. bundle failed because of a conflict, though, so I had to bundle update and then it worked.
My relatively basic app was working fine then all of a sudden I ran into the following error. I have tried to solve this on my own with no luck. I thank any of you in advance for hoping me to solve this issue.
NoMethodError in Pages#home undefined method `environment' for nil:NilClass (in /Users/kevindark/Site Name/app/assets/stylesheets/application.css.scss)
The exception page indicated the problem was extracted from the stylesheet_link_tag line of code below.
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title><%= #title || "Site Name" %></title>
<%= favicon_link_tag 'favicon.ico' %>
<%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
<%= javascript_include_tag "application", "data-turbolinks-track" => true %>
<%= csrf_meta_tags %>
Adding application.css.scss
/*
* Overwritten by RailsBricks
*
*= require_self
*/
#import "framework_and_overrides";
framework_and_overrides.css.scss available at the link below.
https://gist.github.com/kdark11/9537485
This happened to my Rails app today as well.
It was driving me crazy and your question was the only hit on Google for the problem.
It turns out it was caused by the seemingly-harmless running of "bundle update" (just after adding a gem) which upgraded the 'sprockets' gem to '2.12.0'.
I forced sprockets to use the previous version with:
gem 'sprockets', '2.11.0'
in the Gemfile, then ran
bundle update
...and this solved it for me. edit: restart the server to finish, as the user below stated (thanks). Wow, if I had a dollar for every server restart during development! :-D
Major changes to resources and configuration always require a server restart.
2.12.0 was only released today, so I guess it has a bug or an incompatibility with some other gems we are using. I don't know for sure, I'm a bit of a n00b myself.
I hope this helps!
Edit: For the record, I can verify that faker and sass are not involved as they were installed/upgraded around the same time as the breaking update and I eliminated each. I can't speak for other gems but sprockets definitely is part of the problem here.
Downgrading to:
gem 'sprockets', '2.11.0'
...didn't work for me.
It turned out that I needed to lock slim as well:
gem 'sprockets', '2.11.0'
gem 'slim', '2.0.0'
I ran into this problem while trying to get my app to work. After much trial and error the solution was indeed to update the sprockets gem with:
gem 'sprockets', '2.11.0'
and running
bundle update
Do not forget to restart your rails server, because at first I did not think the solution worked. All that I needed was to restart the server however.
FWIW, I upgraded sprockets to 2.12.3 and I don't get the error anymore. I'm using Rails 4.1.8.
I had this error using Rails 4.2.0 after upgrading from sprockets 2.12.3 to 3.0.1. I needed to actually add the sprockets gem in my Gemfile, and lock the version at 2.12.3.
In my Gemfile:
gem 'sprockets', '2.12.3'
This cleared everything up for me.
I am self-studying Michael Hart's guide and am stuck in chapter 7.
When I go to localhost:3000, an error message comes up, saying it couldn't find file jquery and points to line 7 in application.html.erb file.
when I delete the line 7, -> <%= javascript_include_tag "application", "data-turbolinks-track" => true %>, localhost runs normal without an error.
My git repository.
I solved this by reverting to
gem 'jquery-rails', '2.1.4'
gem 'jquery-ui-rails', '4.2.1'
I asume you did'nt run 'bundle install' because:
In application.js you require jquery which should usually come with the the gem 'jquery-rails', '2.2.1'
I removed Gemfile.lock and ran bundle install once again, and it solved the problem.
I solved this by... restarting server! It recollected the libraries and worked like charm.
I've been browsing stack overflow and I noticed that many people use simple_form to make their lives easier.
I wanted to give it a try, so I added the gem to my gem file (gem 'simple_form') and sent:
rails generate simple_form:install --bootstrap
After reading the installation message, I created a view with the sample code from the readme:
<%= simple_form_for #user do |f| %>
<%= f.input :username %>
<%= f.input :password %>
<%= f.button :submit %>
<% end %>
Unfortunately, I get this error as soon as I try to load the page:
undefined method `simple_form_for' for #<#<Class:0x69dd688>:0x6903ac8>
What gives? How come it can't even recognize the method? I feel like I'm missing something really simply here. Could it be because i'm using bootstrap-sass? Do I need to include a helper in my user controller?
Did you restart your server?
Always keep in mind that after you install a gem or plugin.
Always restart your server
Its all because you didn't restart your server after installing new libraries such as simple_form, devise etc.
Try stop your server and restart it. Your code is perfect!. I encountered this several times. The solution is just restarting the server!.
You must restart your server after installing simple_form gem.
For any absolute beginners. This error will occur if you forgot to install simple_form. To rectify, add this to your Gemfile
gem 'simple_form'
and bundle install
To summarize all possibilities from above, hopefully this list is useful for other gems too.
Check if the simple_form gem is installed correctly
Find the gem in Gemfile and Gemfile.lock. Another way is to run this command in your terminal: bundle list | grep simple_form
If the output is empty
Possibly simple_form isn't installed in your project yet. Since the gem is an external gem, it isn't included in the Rails framework. Rails has its own form library (aka form_with and form_for).
To add simple_form to your project, open the Gemfile and add gem 'simple_form', then run the command in your terminal bundle install.
If the output isn't empty
Check if you have restart the server yet.
After restart the server, and you still not be able to access SimpleForm constant
Check if the gem is set to require: false in Gemfile. If so, remove this part and run bundle install.
You can check if the gem is loaded from rails console by typing rails console or rails c in your terminal.
After the console is loaded, type SimpleForm and hit Enter. In the case there is some errors complaining about the constant is undefined, refer to previous steps to fix.