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 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 11. Jun, 2008
in Rails
I use Netbeans6.1 when developing in Rails. The thing I like most about it is that I can easily read the docs from a certain method in my code. I just press Ctrl + hover my mouse to that method and walla, the docs appears in my IDE. I can also do that when placing [...]
by fadhli
on 06. Jun, 2008
in Programming, Rails
In Rails 2.1, you have a new script/dbconsole Instead of accessing your MySQL database with mysql -u <username> -p You can instead do script/dbconsole and if you database has a password, just do script/dbconsole -p All this works provided that you have the correct database.yml settings.