similar to: inserting multiple rows

Displaying 20 results from an estimated 120 matches similar to: "inserting multiple rows"

2013 Apr 03
1
validates uniqueness scope allow_blank/allow_nil -> validation error
I have this in a model: class GenreBadge < ActiveRecord::Base belongs_to :game, counter_cache: :genre_badges_count, touch: true belongs_to :genre validates :game_id, uniqueness: {scope: :genre_id}, allow_blank: true end When I get one existing genre badge genre_badge = game.genre_badges.first genre_badge.game_id = nil genre_badge.save! It creates an validation exception:
2007 Oct 08
6
spec''in controllers request for nested routes
describe PlayersController, "handling GET /saltmines/games/1/players" do before do @game = mock_model(Game, :to_param => "1") @game.stub_association!(:players, :find => mock_model(Player)) end def do_get get :index, :game_id => @game end it "should be successful" do do_get response.should be_success end it "should
2008 Apr 07
5
Associations errors
undefined method `each'' for 0:Fixnum at line @school = School.find_by_title(params[:school_id].gsub(''-'', " ")) for team in @school.teams ........ end @school does exist cause i tried with .find(:first) and it gave the same error. Also I''m getting undefined method `reject'' for #<Game:0x24ca1c4> From @home.game_ids = @game
2008 Apr 07
7
Saving attribute
Something is getting lost here. def create @home = Team.find_by_user_id(current_user.id) for player in @home.players player.update_attribute(:game_id, @game.id) end end def show @players = Player.find_all_by_game_id(params[:id]) end view <%= @players.size %> # mistakenly equals zero Played with the console and everything should be working fine...
2008 Jan 28
9
Nested matchers
We''re encountering a failure with Mocha 0.5.6. We had this expectation: game_version.expects(:attributes=).with(:game_file => kind_of(GameFile), :game_id => @game.id) This expectation was passing with 0.5.5, but fails with 0.5.6. I added this test to parameter_matcher_acceptance_test.rb, which passes in 0.5.5 and fails in 0.5.6 def test_should_match_nested_parameters
2005 Dec 16
3
sharing layout code among different controllers
I want to have one layout for my whole application. The app has multiple controllers. Is it true that layouts are associated w/ one controller? thanks, etienne -- Posted via http://www.ruby-forum.com/.
2006 Apr 07
5
Confusion about has_many / belongs_to ...
I have a table called players and its model Player, and I have a table called games and its model Game. In the games table I have: player1_id int(11) player2_id int(11) I want the tables to be associated so that I can access the player objects using table.player1 and table.player2 rather than having to lookup the objects based on the ids. I am not sure how to go about this but I suspect I
2006 Jan 01
0
Join table with attributes
Hi folks, I''m trying to migrate a less-than-ideal schema for a Rails app that helps role-playing gamers (the pencil-and-paper type) connect with each other, at http://findplay.anvilwerks.com (the source is available there too, for the curious). The schema currently uses columns for played_games, wanted_games, and favorite_games in the players table; each of these holds a foreign key to
2012 Jul 17
0
Email Exception
Dear All, I would like to know How to Mailer Exception Handling. In My Project, I send email to all contact and view messages. Whatever emails is wrong, not send email, I wanna keep on process. UserMailer.message_email(@to_user,subject,message).deliver player = Player.new() player.user_id = current_user.id player.game_id = @game.id player.ishost = true I wanna do
2010 Dec 01
0
Thinking sphinx + rails 3 issue in results set
Hi All, I am using rails 3.0 and i installed sphinx and added the following to gemfile gem ''thinking-sphinx'', ''2.0.0'', :require => ''thinking_sphinx'' My structure is like below: ========================== Model: ===== class User < ActiveRecord::Base include ActionView::Helpers::UrlHelper has_one :profile, :class_name =>
2010 Jul 22
9
Something went wrong.
My app works fine in development on my laptop but in production on my server I get "We''re sorry, but something went wrong. We''ve been notified about this issue and we''ll take a look at it shortly." I am using Rails 3, Ruby 1.8.7, Apache and passenger 2.2.15 I get the welcome aboard page in production if I just go to the domain name but as soon as I want data
2008 May 08
6
[Bug 15864] New: when linked to gst-ffmpeg crash ff3 when full screen play
http://bugs.freedesktop.org/show_bug.cgi?id=15864 Summary: when linked to gst-ffmpeg crash ff3 when full screen play Product: swfdec Version: 0.7.x Platform: x86-64 (AMD64) OS/Version: Linux (All) Status: NEW Severity: normal Priority: medium Component: plugin AssignedTo: swfdec
2006 Jan 20
11
HABTM relations
Hi, I have 3 tables with HABTM relation. USERS -> QUOTE_TO_USER <- QUOTES Table QUOTE_TO_USER has 3 attributes: quote_id, user_id, component. I have a form where I can tie multiple users to QUOTE. This is easy one, thru "user_ids" (@quote[:user_ids] = @params[:quote][:user_ids]). In this form I have all users and I just check those I want to tie to this quote, however
2007 Apr 03
2
has_many :through associated object ids assignment error
Hi, I have the following situation: class Article < ActiveRecord::Base has_many :readings has_many :users, :through => :readings end class Reading < ActiveRecord::Base belongs_to :article belongs_to :user end Now what I''m trying to do is: article = Article.new article.save! # user ids 1,2,3 exist in database, as does the article article.user_ids = [ 1, 2, 3 ] But I
2006 Jul 26
8
team captain - habtm w/has_one...
the below... class User < ActiveRecord::Base has_and_belongs_to_many :teams class Team < ActiveRecord::Base has_and_belongs_to_many :users has_one :captain, :class_name => ''User'' produces the error... Mysql::Error: Unknown column ''users.team_id'' in ''where clause'': SELECT * FROM users WHERE (users.team_id = 1) LIMIT 1 i
2006 Sep 28
5
Eager loading using find_by_sql
Here''s the problem I have the following models User - is a person Team - is a team Wherenote - snipet of info about a user''s whereabouts on a certain day Team has_and_belongs_to_many :users User has_and_belongs_to_many :teams has_many :wherenotes Wherenote belongs_to :user each Wherenote has a note_date On one page I want to pull back all the Users from a particular Team
2012 Nov 13
1
help formatting data for clustering
Hi, I'm a R beginner. I have data of this form: user_id, brand_id1, brand_id2, ..... for example: 1 , 45 , 32, 45, 23 2 , 34 4, 11, 43, 45 I'm looking for the right procedure to be able to cluster users. I am especially interested to know which functions to use at each step. I am currently able to load the data in a data frame, each row's name being the user id. #extract user
2006 Dec 25
2
how to insert data using has_and_belongs_to_many
I''am newbie in RoR, so my question might look stupid, but I stuck in one thing. I''ve created 3 tables: users{ id, user } books { id, book } books_users{ book_id, user_id} Model class Book< ActiveRecord::Base has_and_belongs_to_many:users I can''t figure out how to insert data to the books_users table. For example users post info about new book and information
2007 Apr 16
5
AAF: merge search results
Hi, I have a user model that has a couple of other models(like street address, tasks). suppose User has a name field Address has a state field. so I want to provide a detailed search form each field in the user and its related models can be specified. Suppose I have a user that has a name "california", and that user has a address with the state field being "california" as
2006 Jun 22
3
best way to generate sums of groups
I''m a rails newby, so I''m trying to wrap my head around how to tackle this, since my first few attempts failed. Let''s say your database looks like this: Users id, name, created_at Points id, user_id, value, created_at Users complete different tasks and are awarded varying levels of points, which are recorded in the Points table. What if you wanted to display a