On Aug 29, 2012, at 12:04 PM, Colin Law wrote:
> On 29 August 2012 16:13, Walter Lee Davis <waltd@wdstudio.com> wrote:
>> I have a model that includes a :current boolean. The idea is that there are many home pages that the admin is working on at any given time, but only one is current at a time. At the moment, I have enforced this with the following:
>
> I think you may have this the wrong way round, instead of remembering
> which one is current in the page put it in the admin model, then you
> only need to change it there and not touch the pages at all.
Admin is a subset of User, I was referring to him or her as a person, not a model. I am not sure why that model would be the place, though. I want to route /home to homes#default, where homes_controller#default looks like this:
def default
@home = Home.default
render :action => 'show'
end
and home#default looks like this:
def self.default
@default ||= Home.where(:current => true).first || Home.order('added_at DESC').first || Home.new
end
This is all working, I was just looking for a way to make it more canonical.
Walter
>
> Colin
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment