Feeds:
Posts
Comments

Posts Tagged ‘Ruby on Rails’

Basic rule is; If you don’t need to do anything with the relationship model, it may be simpler to set up a has_and_belongs_to_many relationship. You should use has_many :through if you need validations, callbacks, or extra attributes on the join model. For example; Stories can belong to many categories. Categories can have many stories. For [...]

Read Full Post »

Rails new vs build

new creates a blank new instance, filling attributes with the passed params. It is only used on a Model class: @post = Post.new(attributes) build is only used on association proxies, not on classes, and it does the same as new, but it also sets the foreign key to the id of the parent element: @comment [...]

Read Full Post »

If you are using select (or similar helpers such as collection_select, select_tag) to set a belongs_to association you must pass the name of the foreign key (in the example below blog_id), not the name of association itself. If you specify blog instead of blog_id Active Record will raise an error along the lines of ActiveRecord::AssociationTypeMismatch: [...]

Read Full Post »

Try; f.select not f.select_tag That should work.

Read Full Post »

Got this issue. No worries. Open up environment.rb and Add; config.gem ‘twitter-auth’, :lib => ‘twitter_auth’ That should fix ur issue

Read Full Post »

Faced this isuue after upgrading to Rails-2. Removing “encoding: utf8″ from database.yml fixed the problem. Don’t know the exact reason. May be included with the rails core?. Suggestions welcome.

Read Full Post »

The –prefic option in mongrel configuration causes this error. Go to RAILS_APP/config/mogrel_cluster.yml and remove the “prefix” option If you are having problem in starting the server, without “–prefix” option.  Pls refer the workaroung suggested. (http://www.nabble.com/Problem-when-migrating-from-rails-2.2.2-to-rails-2.3.2-on-linux–SLES10-%2B-apache-2-td22961256.html) Copy this file in my_rails_app/config/initializers : abstract_request.rb module ActionController class AbstractRequest < ActionController::Request def self.relative_url_root=(path) ActionController::Base.relative_url_root=(path) end def self.relative_url_root ActionController::Base.relative_url_root [...]

Read Full Post »

If you face an error like this; /usr/local/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/initializer.rb:269:in `require_frameworks’: no such file to load — openssl (RuntimeError) from /usr/local/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/initializer.rb:134:in `process’ Follow these steps: 1. yum install openssl 2. yum install openssl-devel 3. cd /ruby_install_dir/ext/openssl 4. ruby extconf.rb 5. make 6. make install

Read Full Post »

Use the “return” statement to fix this issue. (E.g) def do_something redirect_to(:action => “elsewhere”) and return if monkeys.nil? render :action => “overthere” # won’t be called if monkeys is nil end (copied from http://api.rubyonrails.org/classes/ActionController/Base.html)

Read Full Post »

If you see this errror; ERROR RUNNING ‘cluster::configure’: Plugin /cluster::configure does not exist in category /commands Make sure you have; “mongrel_cluster” gem installed. You can see whether it exists in the list by issuing the command; gem list –local If you don’t see it, run; gem install mongrel_cluster That should fix your issue.

Read Full Post »

« Newer Posts - Older Posts »