[Rails] Re: counting a users adverts and then doing stuff

2009-08-07 Thread bingo bob
Thanks, I've followed your advice (created a maxed_out_adverts?) method in the user model. Works a treat. While I was at it I added a User.max_allowed_adverts column in my DB. I'm quite pleased with myself. However I think the adverts_controller could defo do with a critical eye being cast

[Rails] Re: counting a users adverts and then doing stuff

2009-08-07 Thread bingo bob
Anyone critique that controller - I'd be most gateful. -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ 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

[Rails] Re: counting a users adverts and then doing stuff

2009-08-06 Thread Trausti Thor Johannsson
As yo explain this problem, you could just check the number of adverts the user has in the add function. Something like this pseudo code def add adverts = User.adverts if adverts.length 3 flash too many adverts redirect back else all is normal and the user can add adverts

[Rails] Re: counting a users adverts and then doing stuff

2009-08-06 Thread bingo bob
Aha ! didn't think of this, looks like I've overcomplicated things - of course ! But what do you mean by the add action ? I don't have one. Do you mean the new action in the adverts controller or maybe the create action in the adverts controller or actually a new add action ? bb -- Posted

[Rails] Re: counting a users adverts and then doing stuff

2009-08-06 Thread Trausti Thor Johannsson
Yes, the action in your adverts controller to create new adverts. I usually call these add, not very restful I know. Trausti On Thu, Aug 6, 2009 at 11:44 AM, bingo bob rails-mailing-l...@andreas-s.net wrote: Aha ! didn't think of this, looks like I've overcomplicated things - of course !

[Rails] Re: counting a users adverts and then doing stuff

2009-08-06 Thread bingo bob
OK, but the New action or the Create ? -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ 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

[Rails] Re: counting a users adverts and then doing stuff

2009-08-06 Thread Trausti Thor Johannsson
When a user wants to add an advert, what action does he call first ? Trausti On Thu, Aug 6, 2009 at 11:53 AM, bingo bob rails-mailing-l...@andreas-s.net wrote: OK, but the New action or the Create ? -- Posted via http://www.ruby-forum.com/.

[Rails] Re: counting a users adverts and then doing stuff

2009-08-06 Thread bingo bob
New it is then! and thanks, that's working a treat. Imagine this is more simple than my previously over-engineered idea. -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups

[Rails] Re: counting a users adverts and then doing stuff

2009-08-06 Thread pharrington
On Aug 6, 6:23 am, bingo bob rails-mailing-l...@andreas-s.net wrote: New it is then! and thanks, that's working a treat. Imagine this is more simple than my previously over-engineered idea. -- Posted viahttp://www.ruby-forum.com/. And then when the user POSTs directly to your create

[Rails] Re: counting a users adverts and then doing stuff

2009-08-06 Thread bingo bob
Ok, I'm sold - I'll put it in the model - user model I take it? What's the maxed_adverts? method look like then ? and how do i call it from the create action in the adverts_controller ? -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You

[Rails] Re: counting a users adverts and then doing stuff

2009-08-06 Thread pharrington
On Aug 6, 3:30 pm, bingo bob rails-mailing-l...@andreas-s.net wrote: Ok, I'm sold - I'll put it in the model - user model I take it? What's the maxed_adverts? method look like then ? and how do i call it from the create action in the adverts_controller ? -- Posted