railscasts

railscast 197 how to: function add_fields

廉价感情. 提交于 2020-01-25 12:34:30
问题 I am following the railscast 197 but Im using rails 3.1.3,jquery and scaffold, no nifty:scaffold,everything works fine but I can't add fields, in that episode Ryan Bates give the code for jquery, but is not working for me, here is my code...thanks in advance. in javascript/application.js function remove_fields(link) { $(link).prev("input[type=hidden]").val("1"); $(link).closest(".fields").hide(); } function add_fields(link, association, content) { var new_id = new Date().getTime(); var regexp

railscast 197 how to: function add_fields

社会主义新天地 提交于 2020-01-25 12:33:12
问题 I am following the railscast 197 but Im using rails 3.1.3,jquery and scaffold, no nifty:scaffold,everything works fine but I can't add fields, in that episode Ryan Bates give the code for jquery, but is not working for me, here is my code...thanks in advance. in javascript/application.js function remove_fields(link) { $(link).prev("input[type=hidden]").val("1"); $(link).closest(".fields").hide(); } function add_fields(link, association, content) { var new_id = new Date().getTime(); var regexp

Public_Activity returning an object instead of result

半世苍凉 提交于 2020-01-07 02:58:06
问题 I installed the public_activity gem following the railscasts tutorial. The activities page in the browser is returning an object instead of the actual event that the activity is referring to. class ActivitiesController < ApplicationController def index @activities = PublicActivity::Activity.order("created_at desc") end end Migration responsible for creating a table with activities: class CreateActivities < ActiveRecord::Migration # Create table def self.up create_table :activities do |t| t

Rails - Railscasts nested complex forms

夙愿已清 提交于 2020-01-06 14:33:48
问题 I am using Ryan Bates' Complex Forms Deep Branch, and trying to replicate that example for a form that has two additional nested levels. SurveyName has many SurveyQuestions, which have many SurveyOptions. # application_helper (identical to deep branch) def remove_child_link(name, f) f.hidden_field(:_destroy) + link_to_function(name, "remove_fields(this)") end def add_child_link(name, f, method) fields = new_child_fields(f, method) link_to_function(name, h("insert_fields(this, \"#{method}\", \

Exporting data to csv in rails (railscasts #362)

核能气质少年 提交于 2020-01-05 04:14:26
问题 There are a lot of questions in SO about csv export in rails, but I didn't find one that addresses my problem. I'm trying to export all instances of a model in my rails app, and I was following Ryan Bates' RailsCast #362, but now I'm having problems with the generated CSV. This is my index action in the model controller ( @bookstore is set up in another action, used in a before_filter ): def index @books = @bookstore.books respond_to do |format| format.html format.csv { render text: @books.to

Nested Model Forms - Railscast #196 revised - Adding fields via jQuery not working

不打扰是莪最后的温柔 提交于 2020-01-01 14:36:01
问题 I was following the Railscast #196 revised and everything went basically fine, but I am not able to add new fields to the nested form. The "remove fields" function works nicely, but after click on "link_to_add_fields", the browser jumps to the top of the page, and no new field appears. There are already a ton of questions to this railscast, like here or here, and I tried to read all of them, but most of them are referring to the original casts from 2010. I am stuck for hours now, and I can't

Adding dynamic fields to nested form through AJAX

*爱你&永不变心* 提交于 2019-12-31 22:02:10
问题 I've been watching and reproducing these railscasts on my app: 196-nested-model-form-part-1 and 197-nested-model-form-part-2. I do not yet have a pro account so i can't watch the revised episode. I'm developing under rails4 (edge) and link_to_function has been deprecated in favor of unobstrusive JS (which is great). I'll keep the example of the above railscasts (i.e. survey/question). What i'd like to do is to use the question's partial through unobstrusive javascript and i just don't know

Ruby map method syntax question [duplicate]

一个人想着一个人 提交于 2019-12-30 05:07:45
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: What does map(&:name) mean in Ruby? I was watching railscasts more virtual attributes episode. In that episode, at one point, ryan used a map method syntax which I am not able to understand, Could someone please explain it? tags.map(&:name).join(' ') tags is an object of Tag Model, which has a name attribute. I am able to understand the meaning of this(I think so :)). All the tag object's name attribute are

Rails 3.2.8. Upgrade checkboxes from Rails 1.x.x to 3.2.8

痞子三分冷 提交于 2019-12-25 08:43:48
问题 Just was checking this episode by Ryan Bates and it seems that Rails 3.2.x has different setup. Seems that check_box_tag requires different attributes other than Ryan puts in there. AS it writes back unexpected kEND... to <%= check_box_tag "task_ids[]", task.id %> Any help appreciated 回答1: Your error is unrelated to your use of check_box_tag . " unexpected kEND " indicates an unexpected end-of-file, meaning you've opened a block or other nested structure somewhere and failed to close it.

Rails 3.2.6: Getting 'Unable to access log file' error for development.log file

♀尐吖头ヾ 提交于 2019-12-25 05:22:51
问题 This seems like it would be a common problem, but I just can't seem to find the solution through google searches, etc. I just created a new Rails 3.2.6 application and configured it to use the PostgreSQL database for my local development. I followed this RailsCast and was able to get everything installed and set up correctly. However, whenever I try to do any rails generate or rake commands ( rails generate model , rake db:migrate etc), I get the following error referring to my development