link_to_remote and GET request
If you're working with link_to_remote and you are surprised with a message like the following:
Only get, put, and delete requests are allowed.
then you just need to know that link_to_remote uses POST request by default. All you need is to do is to add :method => :get to the method call.
Use schema.rb to create a new database
Keep the schema.rb file in your Subversion/Git/Mercurial repository and make sure it's up-to-date. It's very useful when you want to create a database without using migrations. You just call rake db:schema:load.
As the documentation states:
"Note that this schema.rb definition is the authoritative source for your database schema. If you need to create the application database on another system, you should be using db:schema:load, not running all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations you'll amass, the slower it'll run and the greater likelihood for issues)."
Showing posts with label migrations. Show all posts
Showing posts with label migrations. Show all posts
Thursday, March 27, 2008
Monday, February 25, 2008
Andrzej's Rails tips #8
Resource controller and 'new' action
If you want to refer to the 'new' action using resource controller, you have to use the 'new_action' method.
BTW, if you want to do the same operation before both 'new' and 'edit' actions in a resource controller, you can do it like that:
Migrations and removing defaults
If you have some default values set on some columns, then you can remove them using ':default => nil'.
Like that:
If you want to refer to the 'new' action using resource controller, you have to use the 'new_action' method.
BTW, if you want to do the same operation before both 'new' and 'edit' actions in a resource controller, you can do it like that:
[new_action, edit].each do |action|
action.before { @product_types = ProductType.find(:all) }
end
Migrations and removing defaults
If you have some default values set on some columns, then you can remove them using ':default => nil'.
Like that:
change_column :users, :name, :string, :default => nil
Subscribe to:
Comments (Atom)