Topic: It works, but is it 'Railsesque'?
I have a data model where a user has one and only one profile, and each profile belongs to one and only one user. I've established this as follows:
class User < ActiveRecord::Base
class Profile < ActiveRecord::Base
Now, I want the user to be able to view his or her very own profile. So in my profile_controller.rb file I have:
class ProfileController < ApplicationController
@profile = Profile.find_by_user_id(@session[:user].id)
And my list.rhtml view is just:
<td><%= @profile.suburb %></td>
Now, this works. After logging in, the user browses to /profile/list, and the profile is listed (well, the suburb is).
However I'm wondering ... is the list action really an appropriate name if there's ever going to be one profile? I'm not sure that the view action is appropriate though, as that's for viewing a particular record, and there's only ever going to be the one of them per user.
Any help would be greatly appreciated ... I don't just want my app to work, I want it to be conventional, both for my peace of mind and for added value for my client.