Chronicling my experiences with ruby on rails, web application development/management.

Showing posts with label tips. Show all posts
Showing posts with label tips. Show all posts

Thursday, March 12, 2009

Weird script/generate scaffold behaviour

As always feel free to correct me if i'm wrong, but here is some wacky behaviour i got when i used the following code to generate scaffolding from rails 2.2.2 core (i.e., no plugins or scaffolding generator plugins at all)


script/generate scaffold affiliate name:string user_id:integer


What was happening to my code was views not being found. restful paths not being found, even when i triple checked my routes file. To solve this i simply reran the code with a capital letter for the model name, as shown below.


What should the code be??


script/generate scaffold Affiliate name:string user_id:integer


Treat scaffold like every model is always CamelCase


By that i mean no matter what the name of your model is going to be always Capitalize the main words for that model. So single word models like Ass, Border, User are good. Never start with a lowercase ass, border or user.


This is just a rule i follow, as i've yet to see it let me down. It might just have been a momentary blip we all experience in our coding life, however capitalized models have never shown me that blip to date, so i'll run with it!

Saturday, November 29, 2008

Updating Rails app from 2.0.2 to 2.2.2

Ahh the fun begins. In this post you will find the 'gotchas' I had with updating an existing established app from rails version 2.0.2 to the new version of 2.2.2.


Cache_template_extensions Error


Here is the partial stack error


/Users/nerb/.gem/ruby/1.8/gems/rails-2.2.2/lib/initializer.rb:530:in `send': undefined method `cache_template_extensions=' for ActionView::Base:Class (NoMethodError)


Solution! - There was mention of an error at line 15 of my environment.rb file. I went to the environments/development.rb and deleted the line
config.action_view.cache_template_extensions = false I read on the interweb that this cache_template_extensions no longer is used or is has been deleted.


Now maybe the time to update Plugins.


As a public service, I wonder if now is the time to update your plugins, if it's been awhile. Some may never change (Acts_as_tree), but some change fairly rapidly (Restful_authentication).


For Restful Authentication, I know there is a new password feature that doesn't jive with the old passwords. However, since I also need to update this plugin, I wonder if it's better to scrap the --old-passsword flag and investigate why the new way is better? Could it be that I may change all of the current user's passwords on my site? Only if there is a dang good reason. A dang good one.

Sunday, November 23, 2008

Acts as ferret : only have one instance per development computer...

Symptoms


I kept getting this stupid error
(druby://localhost:9010) /Users/nerb/.gem/ruby/1.8/gems/activesupport-2.1.2/lib/active_support/dependencies.rb:279:in `load_missing_constant': uninitialized constant Browser (NameError)


How to solve this error


Basically I got this error because Acts as ferret was running in another app on my development box. Just do a simple script/ferret_server stop in the OLD app. Return to the new app and start the ferret server by doing script/ferret_server start


Hell, i thought it had to do with my recent updating of rails to 2.2.2, however, it did not.