search for: find_all_by_user_id

Displaying 6 results from an estimated 6 matches for "find_all_by_user_id".

2008 Mar 17
4
RSpec''ing model association callbacks
...et a 100% coverage of my code but i cannot reach it because i do not understand how to spec my callbacks. Look at this for example: ----------------- User Model class User < ActiveRecord::Base before_destroy :delete_associated_comments def delete_associated_comments comments = Comment.find_all_by_user_id(self.id) comments.each { |c| c.destroy } end end ----------------- User Spec describe User, " being deleted" do before(:each) do end it "should see deleted his own comments" do user = Factory.create_user() comment_1 = Factory.create_comment(:...
2006 Jun 15
6
Newbie''s problem with a nil object he didn''t expect!
Dear Rubyists/Rails gurus, Though I''ve successfully completed the various Rails tutorials online and the Depot application from the Agile Web Development with Rails book, I''m still pretty much a Ruby/Rails newbie. I''m trying to learn by writing my own simple blogging application, but I''ve run into a problem that has had me scratching my head for a few days now.
2010 Aug 18
6
Once I added this HABTM, one of my 'through' relationships, on a non-habtm model, seems to have broke?
...reign_key => "user_id" belongs_to :meter_group, :foreign_key => "meter_group_id" has_many :meters, :through => :meter_group end test "group1 and group2 belong to rachel" do user = User.find_by_login("rachel") subscriptions = Subscription.find_all_by_user_id(user.id) subscriptions.each do |s| meters = s.meters meters.each do |m| puts "meter = #{p m}" end end end However now things are not working since I created some HABTM relationships for meter_group and meters. I end up with the following error: Active...
2006 Feb 02
0
What is best way to show only records belonging to loggeduser?
When I do this, I store the after a successful login. user''s id in session. My controller actions pass that id into the find method @tasks = Task.find_all_by_user_id(session[:user_id]) The session would have to be hacked in order for that to be broken. It''s been secure enough for me. -----Original Message----- From: rails-bounces@lists.rubyonrails.org [mailto:rails-bounces@lists.rubyonrails.org] On Behalf Of Bojan Mihelac Sent: Thursday, February 0...
2012 Oct 26
0
Routing error in rails
In my controller I have def update_project_dates p "It is end date....." @user=User.find(params[:user]) @projects=Project.find_all_by_user_id(@user) end In the view page (only some part of the code is copied and pasted) eventDrop: function() { $.ajax({ url:''/update_project_dates/'', success:function(data) { alert("...
2008 Mar 12
3
undefined method `each' for #<Usrecart:0x46d1678>
I have the an error such as undefined method ''each'' pls can any one find the error from the code given below <center><%=@b%></center> <center><h2>WELCOME IN YOUR PROFILE</h2> <%@usercart=Usrecart.find_by_user_id(@b)%> <%if @usercart.blank?%> <br> <br> <br> <br> <h2>THERE IS NO