Results 1 to 10 of 10
Mar 27, 2009, 06:51 #1
- Join Date
- Jan 2008
- 0 Post(s)
- 0 Thread(s)
Ruby on rails - help with an active record query
I'm still at the early stages of learning so be gentle. However I used want to ask a question about an active record query I am trying to run.
I have set up a table for my users and have populated in, created the model and I can queries against it. I now want the user to be able to visit http://localhost/profile/show/1 (1 being the user_id) and show the stories they have entered. This also has a model and is working properly as I have constructed an index page which lists recent articles and another page which shows them.
However I can't get the articles for a selected user to appear on the profile page.
My code is below...
class ProfileController < ApplicationController def show @user = User.find(params[:id]) @stories = Story.find :all, :conditions => "user_id = params[:id]" end end
<h1>Profile</h1> <p><%= @user.name %></p> <% for story in @stories %> <%= story.headline %> <% end %>