Misc Tips / Edits
Edited line 94 :
Rakefile at the root of your Merb application
rakefile at the root of your Merb application
Edited line 9 :
You can also specify a limited list of actions that will use the filter:
you can also specify a limited list of actions that will use the filter:
Edited line 82 :
Edited line 33 :
Before Filter Conditions
You can pass a condition which must be satisfied before your filter will run using :if and :unless :
before :authenticate, :unless => :logged_in?
The condition can be a Symbol representing a message to send or a Proc which will be called.
Edited line 83 :
Auto-Reload a very-flat app
Auto-Reload a—very-flat app
Edited line 81 :
Auto-Reload a—very-flat app
Add this to your file.
Merb::BootLoader.before_app_loads do
Merb.push_path(:application, Merb.root, File.basename(__FILE__))
end
Edited line 77 :
Custom Rake task
Custom Rake task
Edited line 74 :
Custom Rake task
Add your custom rake task to:rakefile at the root of your Merb application
Edited line 45 :
Also of note, if you generated an app before the new style of merb-freezer, you’ll want to remove the freeze code inside your Rakefile. Otherwise you’ll get errors like “passing in 3 arguments for 2!”
Edited line 59 :
- Create a directory in your config folder named ‘initializers’
- Add the following code to the bottom of your config/init.rb file:
1. Create a directory in your config folder named ‘initializers’
2. Add the following code to the bottom of your config/init.rb file:
Edited line 59 :
1. Create a directory in your config folder named ‘initializers’
2. Add the following code to the bottom of your config/init.rb file:
1. Create a directory in your config folder named ‘initializers’ 2. Add the following code to the bottom of your config/init.rb file:
Edited line 63 :
Dir[Merb.root / 'config' / 'initializers' / '*.rb'] do |initializer|
load(initializer)
end
Dir[Merb.root / 'config' / 'initializers' / '*.rb'] do |initializer|
load(initializer)
end
Edited line 17 :
Before Filter with Arguments
before filter with arguments
Edited line 51 :
Rails-style Initializers
Sometimes you’ll want to initialize a few things when your application starts. If you’re a neat freak, Rails-style initializers may be of use to you. It’s very simple to set this up in Merb:
1. Create a directory in your config folder named ‘initializers’ 2. Add the following code to the bottom of your config/init.rb file:
Dir[Merb.root / 'config' / 'initializers' / '*.rb'] do |initializer|
load(initializer)
end
You’re done! It’s easy, and it keeps things clean.
Edited line 17 :
before filter with arguments
You can also pass arguments to your before filter method using :with => [], like this:
before filter with arguments You can also pass arguments to your before filter method using :with => [], like this:
Edited line 17 :
before filter with arguments You can also pass arguments to your before filter method using :with => [], like this:
You can also pass arguments to your before filter method using :with => [], like this:
Edited line 17 :
You can also pass arguments to your before filter method using :with => [], like this:
Edited line 16 :
def foo(bar)
bar == "baz"
end
Your Controller
before :foo, :with => "baz"
Edited line 26 :
how to write a Merb plugin
TODO: add documentation link. To generate a new plugin:merb-gen plugin merb_awesome
Edited line 7 :
before :authenticate, :exclude => :new
before :authenticate, :exclude => :new
Edited line 12 :
before :authenticate, :only => [:create, :update, :destroy, :new]
before :authenticate, :only => [:create, :update, :destroy, :new]
Edited line 21 :
use_test :rspec, "foo_fixtures" # dependency "foo_fixtures"
use_test :rspec, "foo_fixtures" # dependency "foo_fixtures"
Edited line 21 :
use_test :rspec, "foo_fixtures" # dependency "foo_fixtures"
use_test :rspec, "foo_fixtures" # dependency "foo_fixtures"</pre
Edited line 21 :
use_test :rspec, "foo_fixtures" # dependency "foo_fixtures"</prehow to freeze your Merb app
use_test :rspec, "foo_fixtures" # dependency "foo_fixtures"
Edited line 14 :
use_test dependencies
If your tests require a gem that is not required in your main application code, it’s best not to include the gem when running in the production environment. use_test accepts optional dependency arguments that will only be included in the test environment:use_test :rspec, "foo_fixtures" # dependency "foo_fixtures"
Edited line 1 :
before filter
- h3. before filter
Edited line 1 :
- h3. before filter
before filter
Edited line 1 :
before filter
=before filter=
Edited line 1 :
=before filter=
Edited line 1 :
- before filter
Edited line 2 :
Edited line 2 :
Edited line 3 :
If you wish to use an action before filter but want it to be used on all the actions but one, you will need to use the exclude option:
Edited line 2 :
before :authenticate, :exclude => :newEdited line 7 :
before :authenticate, :exclude => :new
Edited line 13 :
Note that Rails uses
:except => :new while Merb uses :exclude => :new
Note that Rails uses :except => :new while Merb uses :exclude => :new
Edited line 4 :
before :authenticate, :exclude => :new
before :authenticate, :exclude => :new
Edited line 11 :
before :authenticate, :only => [:create, :update, :destroy, :new]
before :authenticate, :only => [:create, :update, :destroy, :new]
Edited line 8 :
you can also specify a limited list of actions that will use the filter:
or
before :authenticate, :only => [:create, :update, :destroy, :new]
Edited line 10 :
before :authenticate, :only => [:create, :update, :destroy, :new]
Edited line 8 :
or
before :authenticate, :only => [:create, :update, :destroy, :new]
or
Edited line 10 :
before :authenticate, :only => [:create, :update, :destroy, :new]
Edited line 4 :
before :authenticate, :exclude => :new
before :authenticate, :exclude => :new
or
before :authenticate, :only => [:create, :update, :destroy, :new]
Edited line 8 :
or
before :authenticate, :only => [:create, :update, :destroy, :new]
Edited line 2 :
Edited line 5 :
Edited line 6 :
before :authenticate, :only => [:create, :update, :destroy, :new]
Edited line 8 :
or
before :authenticate, :only => [:create, :update, :destroy, :new]