skip certain validation method in Model

Update your model to this class Car < ActiveRecord::Base # depending on how you deal with mass-assignment # protection in newer Rails versions, # you might want to uncomment this line # # attr_accessible :skip_method_2 attr_accessor :skip_method_2 validate :method_1, :method_3 validate :method_2, unless: :skip_method_2 private # encapsulation is cool, so we are cool # custom … Read more

Rails naming convention for join table

categories_products. Both plural. In lexical order. Quote: Unless the name of the join table is explicitly specified by using the :join_table option, Active Record creates the name by using the lexical order of the class names. So a join between customer and order models will give the default join table name of “customers_orders” because “c” … Read more

rails – “WARNING: Can’t verify CSRF token authenticity” for json devise requests

EDIT: In Rails 4 I now use what @genkilabs suggests in the comment below: protect_from_forgery with: :null_session, if: Proc.new { |c| c.request.format == ‘application/json’ } Which, instead of completely turning off the built in security, kills off any session that might exist when something hits the server without the CSRF token. skip_before_filter :verify_authenticity_token, :if => … Read more

Rails 3.1: Engine vs. Mountable App

I have noticed the following: Full Engine With a full engine, the parent application inherits the routes from the engine. It is not necessary to specify anything in parent_app/config/routes.rb. Specifying the gem in Gemfile is enough for the parent app to inherit the models, routes etc. The engine routes are specified as: # my_engine/config/routes.rb Rails.application.routes.draw … Read more