[Rails] Creating routes at run-time

2010-07-27 Thread Nick Hoffman
Hey guys. In Rails 2, is there a way to create a route at run-time? I want to do this because a gem that I'm writing requires a single resource route, and I'd prefer that the gem create it at run-time instead of forcing the user to define the route in routes.rb . While trying to figure this out,

[Rails] Reloading controller plugins on each request

2010-04-09 Thread Nick Hoffman
Hey guys. I'm writing an acts_as_X plugin that's used by controllers. Unfortunately, the plugin isn't being reloaded for each request [in the dev env]. I thought that adding config.reload_plugins = true if RAILS_ENV == 'development' to environment.rb , as well as require 'acts_as_X' to my

[Rails] Changing where ActiveRecord logs to in the console

2010-04-01 Thread Nick Hoffman
G'day folks. In the Rails console, if you configure ActiveRecord's logger to output to STDOUT, like this: ActiveRecord::Base.logger = Logger.new STDOUT how do you switch it back to writing to a file? I tried the 2 lines below separately, but AR still logs to STDOUT afterwards:

[Rails] AR inheritance and class methods

2009-06-26 Thread Nick Hoffman
In the code below, p.comments.foobar calls #foobar on every comment. Is there a way to call #foobar only on the comments that belong to post p? class Comment ActiveRecord::Base belongs_to :post def self.foobar; end end class Post ActiveRecord::Base has_many

[Rails] Re: AR inheritance and class methods

2009-06-26 Thread Nick Hoffman
On Jun 26, 3:51 pm, Colin Law clan...@googlemail.com wrote: 2009/6/26 Nick Hoffman n...@deadorange.com: In the code below, p.comments.foobar calls #foobar on every comment. Is there a way to call #foobar only on the comments that belong to post p? class Comment

[Rails] Re: 5 minutes to save 25,000 model objects?

2009-06-12 Thread Nick Hoffman
On Jun 12, 4:54 am, Michael Schuerig mich...@schuerig.de wrote: On Friday 12 June 2009, Nick Hoffman wrote: On Thu, Jun 11, 2009 at 11:24 PM, Ashwin Mangaleashwin.mang...@gmail.com wrote: Try commenting out the uniqueness constraint and check the result. To be fair, the validations

[Rails] Re: 5 minutes to save 25,000 model objects?

2009-06-11 Thread Nick Hoffman
On Thu, Jun 11, 2009 at 11:24 PM, Ashwin Mangaleashwin.mang...@gmail.com wrote: Try commenting out the uniqueness constraint and check the result. To be fair, the validations listed are fairly standard and can be done before the keyword object is created ( client-side using something like ajax

[Rails] Re: 5 minutes to save 25,000 model objects?

2009-06-11 Thread Nick Hoffman
On Jun 11, 11:29 pm, Marnen Laibow-Koser rails-mailing-l...@andreas- s.net wrote: Nick Hoffman wrote: [...] 25,000 model instances is a lot, but 5 minutes seems too long. Any suggestions for how to speed this up? Thanks, Nick Since you're calling k.save each time through the loop

[Rails] Re: map.connect or map.resources?

2008-12-08 Thread Nick Hoffman
On 2008-12-08, at 21:12, Nick wrote: Quick question: Would it be better to use this?: map.resources :maps, :only = [:index] or this?: map.connect '/maps', :controller = :maps, :action = :index Cheers, Nick BTW, that second option should actually be this: map.connect '/maps',

[Rails] Re: Ensuring controller actions have necessary params

2008-11-30 Thread Nick Hoffman
On 2008-11-30, at 16:31, David A. Black wrote: Hi -- One good way to think about it is: if you did have an extra check, what would it do? In other words, if create gets executed and params[:book] is nil, what would you want to happen? Hi David. I was thinking about what do in this

[Rails] Re: Ensuring controller actions have necessary params

2008-11-30 Thread Nick Hoffman
On 2008-11-30, at 18:31, Frederick Cheung wrote: On 30 Nov 2008, at 21:47, Nick Hoffman wrote: On 2008-11-30, at 16:31, David A. Black wrote: Hi -- One good way to think about it is: if you did have an extra check, what would it do? In other words, if create gets executed and params[:book

[Rails] Re: calling a partial from within a model / model's method?

2008-11-24 Thread Nick Hoffman
On 2008-11-24, at 08:37, Joel Oliveira wrote: Hey Nick! First - thanks for the reply. Second - the reason why I'm trying to do this is to allow whatever type of widget model I'm creating to render its own particular partial, in the context of the area a user will place it - header,

[Rails] Nested and non-nested resources, and admin restrictions

2008-11-24 Thread Nick Hoffman
This is a fairly long question, but it's a common one that applies to a lot of applications. Here goes! Many apps have/want a setup similar to this: 1) ModelA has many ModelBs (Eg: User has many Photos). 2) Admins CRUD all photos at /photos and beyond (Eg: /photos/1/edit). 3) Admins CRUD User

[Rails] Namespacing conventions

2008-11-24 Thread Nick Hoffman
I compared the output from ``rake routes'' for each solution below, and they both produce the exact same routes. Is one solution preferred over the over? # Solution #1: map.resource :account do |account| account.resources :properties, :controller = 'account/properties'

[Rails] Re: Controller DRYness question

2008-11-16 Thread Nick Hoffman
G'day Justin. That's a great suggestion. I would actually prefer using a helper method over putting the call to ModelObject#find in the view itself. Something about calling find directly from the view just doesn't feel right to me. The only reason I'm not 100% opposed to it is because a

[Rails] Re: Authentication including Authorization (Roles/Rights/Permissions)

2008-11-11 Thread Nick Hoffman
Adriano Ferreira wrote: It's been couple of days messing around with Internet looking for a good Authentication including Autorization system/plugin for Ruby On Rails. I've found lots of sources related to that. However, most of them are old, not frequently updated, not even well

[Rails] Re: Rails authorization

2008-11-11 Thread Nick Hoffman
Daniel Lopes wrote: Hello, anyone know who is the best plug-in for authorization in rails? I found this link http://www.vaporbase.com/postings/Authorization_in_Rails but is old, maybe today we have something better. Thanks. There's no best. Every situation is different. You need to

[Rails] Re: code to allow only friends.

2008-11-11 Thread Nick Hoffman
Santosh Turamari wrote: I have an app in which, I have profiles which has friends list.. I want to apply some privacy settings as to allow, to visit only their friends in network..How to write the code in controller.. can anybody pls explain me.. I am new to ror. That's just implementating

[Rails] What is :chained_replace_html ?

2008-09-29 Thread Nick Hoffman
I'm testing an XHR, and until I discovered :chained_replace_html , the test wasn't seeing that a div was being hidden. === map_filter.rjs 22 page['map-filter-errors'].hide === Why does line 433 above fail?: === neighbourhoods_controller_spec.rb 432 do_xhr @xhr_params 433