In some cases, you may want to have multiple foreign keys map to a single model. The following example explains how the “user_id” and “favorite_id” in a single table(Favourites) map to the User Model(table). class Favourite < ActiveRecord::Base belongs_to :user belongs_to :favourite_user, :class_name => “User”, :foreign_key => “favourite_id” end Now you can play around without [...]
Posts Tagged ‘Ruby on Rails’
Handling Multiple foreign keys in Rails
Posted in Ruby on Rails, tagged lessons, Ruby on Rails on December 15, 2008 | Leave a Comment »
Rails request.env[:HTTP_REFERER] returning nil
Posted in Ruby on Rails, tagged bug fixes, Ruby on Rails on December 10, 2008 | Leave a Comment »
Try, request.env[:REQUEST_URI] instead. That should fix your problem.
Rails resources error – undefined method ‘site_*’ -using namespace
Posted in Ruby on Rails, Weird Errors, tagged bug fixes, Ruby on Rails on December 8, 2008 | Leave a Comment »
If you use the namespace route like the one below : map.namespace :user do |user| user.resources :invitations end Make sure you have the links like the following; <% form_for([:user,@invitations]) do |f| %> Don’t try with; <% form_for([@user,@invitation]) do |f| %>
Rails Migration symbols – Data Types
Posted in Ruby on Rails, tagged lessons, programming, Ruby on Rails on December 4, 2008 | Leave a Comment »
Migration column type… Converts to MySQL field type… Available options :binary TINYBLOB, BLOB, MEDIUMBLOB, or LONGBLOB2 :limit => 1 to 4294967296 (default = 65536)2 :boolean TINYINT(1) – :date DATE – :datetime DATETIME – :decimal DECIMAL :precision => 1 to 63 (default = 10) :scale => 0 to 30 (default = 0)3 :float FLOAT – :integer [...]
undefined method ‘model’ in application.rb
Posted in Ruby on Rails, Weird Errors, tagged bug fixes, Ruby on Rails on December 1, 2008 | Leave a Comment »
I think you’re running Rails 2. This line will work only with Rails 1. The ‘model’ method is no longer supported.Remove that line from the code. (E.g) undefined method `model’ for ApplicationController:Class – Line 12 in applicaton.rb
Undefined method ‘cache_template_extensions=’
Posted in Ruby on Rails, tagged bug fixes, Ruby on Rails on December 1, 2008 | 1 Comment »
The simple fix is to remove it from my config/environments/development.rb (or) production.rb file as it’s now been deprecated.
Install Ferret on windows
Posted in Ruby on Rails, tagged installations, lessons, Ruby on Rails on December 1, 2008 | Leave a Comment »
Download the ferret gem for windows from http://rubyforge.org/frs/?group_id=1028 (E.g) http://rubyforge.org/frs/download.php/34135/ferret-0.11.6-mswin32.gem Move to the directory where you downloaded the gem (cd Desktop/<download-location>) and do gem install <filename> (E.g) gem install ferret-0.11.6-mswin32.gem You may also need, gem install acts_as_ferret, for your project.
The procedure entry point mysql_stmt_row_tell could not be located in the dynamic link library LIBMYSQL.dll
Posted in Weird Errors, tagged bug fixes, lessons, MySQL, Ruby on Rails on November 25, 2008 | Leave a Comment »
If you are getting the following error, here is a quick fix that will get you working again. You will need to manually copy the libmysql.dll to the rubybin directory. Search for libmysql.dll file and copy it to the rubybin folder and
The dynamic link library LIBMYSQL.dll could not be found in the specified path
Posted in Ruby on Rails, Weird Errors, tagged MySQL, Ruby on Rails, tips, windows on November 25, 2008 | Leave a Comment »
When you find this error alert in windows, make sure you do one of the following; Find the LIBMYSQL.dll file and add its location to the PATH(environment-variable) (or) copy LIBMYSQL.dll to the System32 directory.
ERROR : could not find gem rails locally or in a repository
Posted in Weird Errors, tagged bug fixes, installations, lessons, Ruby on Rails, tips on November 25, 2008 | Leave a Comment »
If you find this error during rails installation, one solution may be this. Setting up http proxy Gem install behind proxy – MAC