by fefe
on 16. Mar, 2010
in Rails, Ruby On Rails
My colleague and I were working on a feature to apply dynamic subdomain name in one of our rails apps. Since a lot of documentation out there only focus on how to host subdomain app by configuring the /etc/hosts file. I reckon I share some insight on how to actually enable dynamic subdomain in your [...]
by fadhli
on 22. Oct, 2009
in Rails
Have been tinkering around with authlogic. The most I love about is its out-of-the-box functionality. I used to wrestle with restful_authentication to get certain things that I need. Not in anyway that I’m bashing it but seeing how easy authlogic I couldn’t believe why I didn’t use it sooner. I like it so much that [...]
by fadhli
on 14. Jun, 2009
in Rails
Getting your bug fix/code pulled into the main repo really gets you excited & satisfied. I never thought it could give me this much sense of enjoyment. Check it out. http://github.com/dmix/weekly_builder/tree/master
by fadhli
on 08. Jun, 2009
in Rails
I’m figuring out something in my rails app. I’m figuring out which one’s the worst: Eager loading 100 rows of data you don’t actually need at the moment or 10 queries giving 10 result set at once? Here’s the code to explain it. 1 2 3 @event = Event.find(params[:event_id]) @event_attendees = @event.attendees.paginate(:page => params[:page], [...]
by fadhli
on 18. Dec, 2008
in Rails
Something peculiar happened when I was doing something trivial. If you accidently named your restful route the following resource :roles instead of resources :roles When you point your app to /roles it won’t go to your index controller action but it will instead call your show action.
by fadhli
on 20. Nov, 2008
in Rails
I had trouble reindexing the ferret index using the rake command (rake ferret:rebuild). I got this non-descriptive error regarding failing to rebuild it (Even in my development mode). So after googling for it, all one has to do is so simple. Go into your rails script/console and just type Model.rebuild_index And you’re done.
by fadhli
on 22. Jul, 2008
in Programming, Rails
For example: id |category_id | inventory_id 1 384 1 #first entry 2 384 2 #this would be ok. 3 384 1 #this would not be ok To ensure that a category_id doesn’t have any inventory_id duplicate: [sourcecode language="ruby"] class CategoryProduct < ActiveRecord::Base belongs_to :category belongs_to :inventory validates_uniqueness_of :category_id, :scope => :inventory_id end [...]
by fadhli
on 15. Jul, 2008
in Rails
A good read on table index. http://www.railway.at/articles/2008/04/24/database-agnostic-database-ignorant Sometimes, it is easy to forget when someone or something else handles it for you. For instance, ActiveRecords. Rails does not create foreign keys for you. It only creates the primary key. It does not impose constraint on the database level. The association is handled on the application [...]
by fadhli
on 14. Jul, 2008
in Programming, Rails
Do not name your database column with the name ‘no’. You’ll get this error when you try to run your test ActiveRecord::StatementInvalid: Mysql::Error: Unknown column ‘false’ in ‘field list’
by asyraf
on 20. Jun, 2008
in Programming, Rails
I was wondering how to keep the layouts in my rails application code DRY – I was close to the point of kicking myself for having to make changes to all my layouts whenever something standard changed – so i researched online and found the above diagram by Matt McCray in his blog. I used [...]