similar to: Noob - Associated Tables Find Query

Displaying 20 results from an estimated 6000 matches similar to: "Noob - Associated Tables Find Query"

2006 Mar 16
3
inserted_at seems buggy in production mode?
Hi, I''ve got a table with an inserted_at column. When I insert a record it automatically injects the current date/time, all is well. Then when I insert a second record, it uses the exact same timestamp that is used in the first record. This behavior only seems to occur in production mode. When I restart the server, the problem goes away but then immidetatly occurs again on the
2006 Jan 19
2
NOOB: Using locals to pass data to a SQL query
I want to show a users entries based on there login id. I have tried this: View: <div id="myfish"> <%= render :partial => ''myfish'', :locals => {:user => session [:user].id } %> </div> Partial: <% for entry in @entries %> <table border ="0" CELLSPACING="0"> <tr class="<%= alternate
2006 Jan 10
3
Getting a user from a model (sort of a noob) (resend sorry)
Sorry for the resend but I am not sure if the first one ever made the list. As mentioned in my previous posts I''m trying to create a dynamic directory for file_folumn. After finding out that I didn''t have the most recent version I installed the latest trunk and am able to get file_column to act as it should. However I have been racking my brain on how to implement
2006 Mar 08
4
RMagick Instant Rails install problem
Anyone help with this? Am running Instant Rails on Win XP Sp2. Have downloaded the RMagick-win32-1.9.2 files into c:\Instant-Rails-1.0\temp from the rubyforge site. Running "Gem install RMagick-win32-1.9.2-mswin32.gem" from the temp directory seems to work giving me a "Successfully installed RMagick-win32, version 1.9.2" message. However, when I then try and go
2006 Jan 23
15
Looking for DB/Model Design Suggestions
Hi, I''m working on an app - my first Rails - and am looking for some suggestions on the best way (or good way) to set up my models / DB. In general there are teams and matches; a team will participate in multiple matches, and in each match there will be 6 teams - 3 vs. 3. I''m going to want to be able, for a particular team, pull up all matches for that team, to display a
2005 May 17
2
Noob - ActionView::Helpers::FormOptionsHelper::select
Hi, I''m just starting with Rails and i''m trying to do something like this: <%= start_form_tag :action => ''add_user'', :id => @social_event_group %> <%= select ''user'', ''id'' , User.find_all.collect {|u| [ u.login, u.id ] }%></p> <%= submit_tag "Add User" %> <%= end_form_tag %>
2006 Feb 16
1
validations with associated object
Does anyone know if Rails is supposed to validate associated objects on creation? Say you have a User model, with has_many posts, and a Post model which belongs_to user. Further, the Post model has a validates_uniqueness_of :title. u = User.find(1) # this should pass u.posts.create :title => ''my new post title'' # this should fail u.posts.create :title => ''my
2006 May 17
4
NOOB: Representing linked objects in one form
Given two models: User :name :email :address_id # foreign key Address :line_1 :line_2 :city etc. I want to have a form allowing a user to register, in which she''d enter an address as well, but how do I go about combining both objects into the one form? I''m new to this and following along with the Agile Rails book from the Pragmatic Programmers, but it
2009 Jan 04
3
Table associated problem using belongs_to
I have two tables: Table [packages] id name user_name ------------------- 1 PK1 Ray ------------------- Table [users] id name full_name ------------------- 2 Ray Ray Sun ------------------- My purpose is to find the full name when I find packages. So I modify Model Package to: class Package < ActiveRecord::Base belongs_to :user, :class_name => "User",
2009 Mar 11
12
Eager loading comments associated with user submissions.
Hey everyone, I am working on an application that allows users to submit articles, and also comment on those articles. Pretty much exactly like Digg. Everything works fine except that when there are a lot of comments there are a lot of database queries to both fetch the comments and the users who posted those comments. I have used eager loading in other parts of my application to reduce the
2007 Dec 19
6
thread_pooling sleeping
I''m trying to run a single worker that could perform a periodic task for a given user. >From a controller, I imagine something like: def start_job MiddleMan.ask_work(:worker => :foo_worker, :worker_method => :perform_task, :data => { :user_id = current_user.id }) end def check_job @status = MiddleMan.ask_status(:worker => :foo_worker)[current_user.id] end
2006 Feb 16
6
session usage
Clearly I have the session and can see that session[:user_id] = 7 Now I want to use the results of this...in a page...so I am trying to use the instance variable @sess_user and at the top of the application controller, I have either... @sess_user = User.find([:first, "id = ?", session[:user_id]) or @sess_user = User.find([:first, "id = ?", session[:user_id]) gives me an
2009 Nov 09
3
How can I improve a Ruby on Rails code that hast a lot of SQL as strings?
Hello Railists, I have a piece of Ruby on Rails code that has a complex SQL query (well, not that complex, but as far as I know beyond the ORM capabilities) and for my taste it has too many strings and harcoded values. I''d like to improve it as much as possible, so my question is open ended, what else can I do to improve it? Some particular issues I have - Is there a way to get a table
2005 Dec 14
5
inserting multiple rows
I have table which stores multiple entries. Each row has user_id, game_id and a pick_id. On a page the user has to make load of choices. All this gets submitted. the html looks like so: <input type="hidden" name="game_id" value="3"> <input type="hidden" name="user_id" value="19"> <select name="pick[3]"> ....
2007 Jul 12
3
Agh, this is annoying. Why is this happening?
My problem: Mock ''Task_1005'' received unexpected message :user_id= with (1) No matter what I do to try to stub that out it will still fail out and give me that message. Here is my spec describe TasksController, "handling POST /tasks" do before(:each) do @task = mock_model(Task, :to_param => "1", :save => true)
2009 Jul 04
9
prevent orphan records
If I have belongs_to :user Do I need to have validates_presence_of :user_id ? Does Rails validate the presence of :user_id automatically if I have belongs_to :user? In other words, does Rails prevent against creating orphan records that belong to non-existent users? Thanks. -- Posted via http://www.ruby-forum.com/.
2013 Jan 24
12
group by + sum
Hi.. I need some support... table: week_id, user_id, project_id, hours ex. => 33, 2, 1, 10 34, 2,1,15 33, 2, 2, 20 35, 3, 1,20 etc. Want to display a sum of hours per week_id per user_id I have: @hours = HourUser.includes(:user).group_by { |h| h.week_id } @hours.keys.sort.each do |hour| @hours[hour].collect(&:stunden).sum Hours are summed up, but not sorted by user_id.. How to get
2006 Jan 19
8
I can''t figure out how to solve this one
I am creating an application to run a fishing tournament (see http:// www.ruby-forum.com/topic/51209 for a little background) Now I am running into an issue trying to calculate a leader board. each participate can enter multiple fish but only the largest fish per a given species counts towards the overall score. My entries table looks like this:
2006 Jul 07
4
need help with some ugly code - is there a better way?
Hi, In my user_controller.rb, I have the following method, which is supposed to send the user to their profile, dependng on what "role" they are (the roles correspond to the other controllers: venue, band, fan): def login if request.post? if session[:user_id] = User.authenticate(params[:user][:login], params[:user][:password]) flash[:message] =
2010 Nov 30
4
Cucumber+Capybara rails 3 issue (Don't know where exactly)
When I''m executing cucumber tests, I noticed that sometimes rails app (in test env.) getting several the same requests (GET or POST) usually around 3, and it doesn''t render anything with empty HTTP status code. Have anyone met something similar to that issue? here is some example of log file: Started POST "/account" for 127.0.0.1 at 2010-11-30 22:34:17 +0200