ruby-on-rails-3

Undefined method _s_path in form_for

别等时光非礼了梦想. 提交于 2020-01-01 19:32:14
问题 I know there are a bunch of questions on this. I've looked around, but I don't seem to be making the mistakes I've found answers to. The form for my workout resource, nested under users, is giving the error undefined method `workouts_path' for #<#<Class:0x007f88939c9e60>:0x007f8891527b20> That form goes: = form_for @workout do |f| ... = f.submit The Workouts Controller new action (where the error's being produced): def new @user = User.find(params[:user_id]) @workout = @user.workouts.new end

Ajax callbacks not working with Rails 3.0.5 and jQuery 1.5.1

元气小坏坏 提交于 2020-01-01 19:21:12
问题 I've got ajax pagination working with the Kaminari gem on my website but I'm having difficulty getting ajax callbacks working I'm using jquery-1.5.1, rails 3.0.5 and I have the latest rails.js file My podcasts.html.haml looks as follows #paginator = paginate @podcasts, :remote => true #podcasts = render @podcasts My index.js.erb file looks like this: $('#podcasts').html('<%= escape_javascript render(@podcasts) %>'); $('#paginator').html('<%= escape_javascript(paginate(@podcasts, :remote =>

Ajax callbacks not working with Rails 3.0.5 and jQuery 1.5.1

﹥>﹥吖頭↗ 提交于 2020-01-01 19:21:08
问题 I've got ajax pagination working with the Kaminari gem on my website but I'm having difficulty getting ajax callbacks working I'm using jquery-1.5.1, rails 3.0.5 and I have the latest rails.js file My podcasts.html.haml looks as follows #paginator = paginate @podcasts, :remote => true #podcasts = render @podcasts My index.js.erb file looks like this: $('#podcasts').html('<%= escape_javascript render(@podcasts) %>'); $('#paginator').html('<%= escape_javascript(paginate(@podcasts, :remote =>

How to integrate previously external ruby scripts into a Rails app and call them from a rake task?

本秂侑毒 提交于 2020-01-01 19:15:31
问题 I have some additional scripts that I've written outside of my Rails 3.1.x app, however the time has come to pull data from the database of the Rails app directly rather than utilizing some exports of the data. To this end, I'd like to integrate the scripts into my rails app. Hitherto I've run rake tasks based on methods in the models such as having this in my lib/taks/app.rake : desc "Does something." task :do_some_things => :environment do ModelName.some_method ModelName.another_method end

nested_form, collection_select, accepts_nested_attributes_for and fields_for, and adding records to a join table

大憨熊 提交于 2020-01-01 19:13:33
问题 Update: according to the stack trace, posted at the end of this question, I think the real problem is to figure out what attr_accessible and build association settings I need to get the contributors and linkers attributes to update with the new isbn id. Please help me! Following on from this question... I've got a join table between two models - isbns and contributors - which have a many to many relationship. I want to use the existing values from the contributor model in a collection_select

nested_form, collection_select, accepts_nested_attributes_for and fields_for, and adding records to a join table

本秂侑毒 提交于 2020-01-01 19:13:12
问题 Update: according to the stack trace, posted at the end of this question, I think the real problem is to figure out what attr_accessible and build association settings I need to get the contributors and linkers attributes to update with the new isbn id. Please help me! Following on from this question... I've got a join table between two models - isbns and contributors - which have a many to many relationship. I want to use the existing values from the contributor model in a collection_select

Rails VERY slow in development using Ubuntu VVM

左心房为你撑大大i 提交于 2020-01-01 19:00:15
问题 I have the following config Ubuntu server 10.04 running on a VirtualBox VM (RAM and cpu usage are low) ruby 1.9.3 rails 3.2.12 webrick If I do any of the things below the system seems to wait for about 15 seconds before executing the command - rake taks - rails s - navigating to a new page in the app Things I have looked at - this is before the sprockets section, and does the same with rake, so at the moment I am not looking at things such as dev-tweaks - I have changed the webrick config.rb

Help with sorting records in Ruby on Rails

丶灬走出姿态 提交于 2020-01-01 18:58:30
问题 I have a score table that contains two columns: user_id and score user_id score 1 200 1 120 1 230 2 300 2 345 3 100 3 40 4 350 4 500 ...... Score.order('score DESC').limit(3) lists the top 3 scores. Instead, how would I get the top 3 scores where each user only gets one spot on the list (their highest score). The high scores from the above table would be: user_id: 4 score: 500 user_id: 2 score: 345 user_id: 1 score: 230 Thanks! Tim 回答1: You should be able to group your query: Score.order(

Help with sorting records in Ruby on Rails

左心房为你撑大大i 提交于 2020-01-01 18:58:09
问题 I have a score table that contains two columns: user_id and score user_id score 1 200 1 120 1 230 2 300 2 345 3 100 3 40 4 350 4 500 ...... Score.order('score DESC').limit(3) lists the top 3 scores. Instead, how would I get the top 3 scores where each user only gets one spot on the list (their highest score). The high scores from the above table would be: user_id: 4 score: 500 user_id: 2 score: 345 user_id: 1 score: 230 Thanks! Tim 回答1: You should be able to group your query: Score.order(

Rails notification system

隐身守侯 提交于 2020-01-01 18:47:07
问题 I need to create a facebook-like notification system for an app I am working on. I was wondering what suggestions any of you have for how to go about doing this? If possible, I would like to avoid using the database for the notifications, if this is feasible I'd love to know how. Thanks in advance 回答1: It wasn't clear in the question if notices needed to persist across sessions or user-to-user (who may not be online at the same time); however, I had a similar need on a Rails app and