Misc Tips / Edits

6 days ago

Edited line 94 :

Rakefile
at the root of your Merb application
rakefile
at the root of your Merb application

6 days ago

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:

7 days ago

19 days ago

Edited line 82 :

Dir[Merb.root / 'config' / 'initializers' / '*.rb'].each do |initializer|
Dir[Merb.root / 'config' / 'initializers' / '*.rb'] do |initializer|

3 months ago

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.

3 months ago

Edited line 83 :

Auto-Reload a very-flat app

Auto-Reload a—very-flat app

3 months ago

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 

3 months ago

Edited line 77 :

Custom Rake task

Custom Rake task

3 months ago

Edited line 74 :

Custom Rake task

Add your custom rake task to:
rakefile
at the root of your Merb application

3 months ago

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!”

3 months ago

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:

3 months ago

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:

3 months ago

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

3 months ago

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.

3 months ago

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:

3 months ago

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:

3 months ago

Edited line 17 :

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:

3 months ago

Edited line 16 :

You can also pass arguments to your before filter method using :with => [], like this: Your method defined elsewhere
 
def foo(bar) 
  bar == "baz"  
end 
Your Controller
 
before :foo, :with => "baz"  

3 months ago

Edited line 26 :

how to write a Merb plugin

TODO: add documentation link. To generate a new plugin:
merb-gen plugin merb_awesome

4 months ago

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"

4 months ago

Edited line 21 :

use_test :rspec, "foo_fixtures"    # dependency "foo_fixtures"
use_test :rspec, "foo_fixtures"    # dependency "foo_fixtures"</pre 

4 months ago

Edited line 26 :

For more info read this blog post

4 months ago

Edited line 21 :

use_test :rspec, "foo_fixtures"    # dependency "foo_fixtures"</pre 
 
	

how to freeze your Merb app

read more there

use_test :rspec, "foo_fixtures"    # dependency "foo_fixtures"

4 months ago

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"

4 months ago

Edited line 1 :

before filter

  • h3. before filter

4 months ago

Edited line 1 :

  • h3. before filter

before filter

4 months ago

Edited line 1 :

before filter

=before filter=

4 months ago

Edited line 1 :

=before filter=

before filter

4 months ago

Edited line 1 :

before filter
  • before filter

4 months ago

Edited line 2 :

  • before filter
  • ==before filter
  • 4 months ago

    Edited line 2 :

  • ==before filter
  • before filter. 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 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:

    4 months ago

    Edited line 2 :

  • before filter. 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:
  • 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:
    before :authenticate, :exclude => :new
  • Edited 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

    4 months ago

    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]

    4 months ago

    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]

    4 months ago

    Edited line 8 :

    or before :authenticate, :only => [:create, :update, :destroy, :new]

    or

    Edited line 10 :

    before :authenticate, :only => [:create, :update, :destroy, :new]

    4 months ago

    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]

    4 months ago

    Edited line 2 :

  • 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:
  • 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 5 :

    Edited line 6 :

    or before :authenticate, :only => [:create, :update, :destroy, :new]

    Edited line 8 :

    or

    before :authenticate, :only => [:create, :update, :destroy, :new]

    4 months ago