railscasts

NoMethodError within nested model form

故事扮演 提交于 2019-12-23 05:12:19
问题 The project is a simple workout creator where you can add exercises to a workout plan. I've been following the Railscast covering nested model forms to allow dynamically adding and deleting exercises, but have run into an error and need a second opinion as a new developer. The error I am continually receiving is: NoMethodError in Plans#show This is the extracted code, with starred line the highlighted error: <fieldset> **<%= link_to_add_fields "Add Exercise", f, :exercise %>** <%= f.text

rails virtual attributes won't read from form_for submission

爷,独闯天下 提交于 2019-12-23 03:32:18
问题 I am trying to implement a rails tagging model as outlined in Ryan Bate's railscast #167. http://railscasts.com/episodes/167-more-on-virtual-attributes This is a great system to use. However, I cannot get the form to submit the tag_names to the controller. The definition for tag_names is : def tag_names @tag_names || tags.map(&:name).join(' ') end Unfortunately, @tag_names never gets assigned on form submission in my case. I cannot figure out why. SO it always defaults to tags.map(&:name)

Nokogiri Segmentation fault?

梦想与她 提交于 2019-12-22 07:25:58
问题 I am trying to run a simple Ruby script from Railscast and once I run my program I get the following Segmentation fault bug error. I have tried uninstalling and reinstalling Nokogiri and LibXML and still nothing. Is there anyway to fix the Ruby 1.87 version? Maybe that is the problem? $ ruby -v ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.7.0] /Users/da/.rvm/gems/ruby-1.9.2-p180/gems/nokogiri-1.4.4/lib/nokogiri/nokogiri.bundle: [BUG] Segmentation fault ruby 1.8.7 (2009-06-12

undefined method `admin?' for nil:NilClass

时间秒杀一切 提交于 2019-12-21 05:04:51
问题 I followed railscast #250 Authentication from Scratch & got everthing wworking fine. Now I'm trying to only display edit & destroy links on my index page to admin user's. I've set up mu User database with a admin boolean field & tried putting a simple if statement in the view of another model (hikingtrails) to only display certain links to admin users but I get this error when I try it out, undefined method 'admin?' for nil:NilClass Database Schema create_table "users", :force => true do |t|

Railscasts Episode #362 - Exporting to Excel: How to avoid the warning message given by Excel 2010 when opening the file?

感情迁移 提交于 2019-12-19 18:26:05
问题 When using the example app from Ryan Bates' Railscasts Episode #362 about exporting to Excel (https://github.com/railscasts/362-exporting-csv-and-excel), I've noticed that Excel 2010 (which is on Windows) gives me a warning message when opening up the .xls file I've downloaded using the "Download as Excel" link. The warning reads: "The file you are trying to open ... is in a different format than specified by the file extension. Verify that the file is not corrupted and is from a trusted

Railscasts Episode #362 - Exporting to Excel: How to avoid the warning message given by Excel 2010 when opening the file?

时光怂恿深爱的人放手 提交于 2019-12-19 18:25:13
问题 When using the example app from Ryan Bates' Railscasts Episode #362 about exporting to Excel (https://github.com/railscasts/362-exporting-csv-and-excel), I've noticed that Excel 2010 (which is on Windows) gives me a warning message when opening up the .xls file I've downloaded using the "Download as Excel" link. The warning reads: "The file you are trying to open ... is in a different format than specified by the file extension. Verify that the file is not corrupted and is from a trusted

Using jquery TokenInput without default 'name'

我们两清 提交于 2019-12-19 04:01:53
问题 Im trying to use the jquery tokeninput found here: http://loopj.com/jquery-tokeninput/ Following the guide from railcasts: http://railscasts.com/episodes/258-token-fields By default, it required a 'name' column on the table/json.. Any way to customize to change it to something else (in my case, 'account_number')? (in the reailcast, he says if you dont have a 'name' column, youll require extra customization) 回答1: The magical lines are <%= f.text_field :author_tokens, "data-pre" => @book

carrierwave - rails 3.1- undefined method: image_will_change

混江龙づ霸主 提交于 2019-12-18 12:14:41
问题 I get an error that look like this: undefined method `post_image_will_change!' for #<Post:0xf4e9184> app/controllers/posts_controller.rb:43:in `new' app/controllers/posts_controller.rb:43:in `create' I've included this in my "post" model: attr_accessible :title, :name, :content, :post_image mount_uploader :post_image, PostImageUploader and in _form.html.erb I've added: :html => { :multipart => true } I looked CarrierWave Error but that doesn't help me. Any clues of what generates that error?

Rails 3 Edit Multiple Records in a Single Form

人走茶凉 提交于 2019-12-18 10:47:19
问题 I've been stuck on this problem for a couple of days now. I've have some success with Railscasts Episode #198, but that one is for Rails 2. There have been some changes in Rails 3 that make it so the code provided in Episode #198 won't work. The problem lies within the edit_individual.html.erb: Original Code (provided by Ryan @ Railscasts): <% form_tag update_individual_products_path, :method => :put do %> <% for product in @products %> <% fields_for "products[]", product do |f| %> <h2><%=h

Unpermitted parameters for Dynamic Forms in Rails 4

和自甴很熟 提交于 2019-12-18 04:24:15
问题 I'm new to Rails and built something based on this http://railscasts.com/episodes/403-dynamic-forms but I have a problem with storing data in the additional fields... I have a ProductType object that has many ProductField objects. The ProductField object also belongs to a ProductType and Product object belongs to a ProductType. So,new dynamic fields can easily be added via the constructor ProductType, but when I try to set data in this fields via Product controller nothing happens. I am sure