Module: BoochTek::Rails::CrudActions
- Defined in:
- lib/rails-crud_actions.rb
Defined Under Namespace
Modules: ClassMethods
Constant Summary collapse
- VERSION =
'0.0.2'
Class Method Summary collapse
Instance Method Summary collapse
- #create ⇒ Object
- #delete ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
-
#index ⇒ Object
This implementation based on blog.boldr.fr/posts/datamapper-0-9-avec-rails before_filter :new_item, :only => [:new, :create] before_filter :find_item, :only => [:show, :edit, :update, :delete, :destroy] before_filter :find_items, :only => [:index] before_filter :fill_item, :only => [:create, :update] TODO: after_filters for finding default views.
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Class Method Details
.included(base) ⇒ Object
9 10 11 |
# File 'lib/rails-crud_actions.rb', line 9 def included(base) base.extend ClassMethods end |
Instance Method Details
#create ⇒ Object
45 46 47 |
# File 'lib/rails-crud_actions.rb', line 45 def create save_or_render 'new' end |
#delete ⇒ Object
42 43 |
# File 'lib/rails-crud_actions.rb', line 42 def delete end |
#destroy ⇒ Object
53 54 55 56 57 58 59 |
# File 'lib/rails-crud_actions.rb', line 53 def destroy @current_item.destroy respond_to do |format| format.html { redirect_to(self.send("#{current_model.table_name.singularize}_index_url")) } format.xml { head :ok } end end |
#edit ⇒ Object
39 40 |
# File 'lib/rails-crud_actions.rb', line 39 def edit end |
#index ⇒ Object
This implementation based on blog.boldr.fr/posts/datamapper-0-9-avec-rails before_filter :new_item, :only => [:new, :create] before_filter :find_item, :only => [:show, :edit, :update, :delete, :destroy] before_filter :find_items, :only => [:index] before_filter :fill_item, :only => [:create, :update] TODO: after_filters for finding default views. TODO: Filtering of items visible to a user. TODO: Complex filtering of index, for searching. (Similar to Justin’s solution.) TODO: User-specifed model or collection. TODO: Pagination. TODO: Automatic rendering of a default page. (Separate module/gem.)
30 31 |
# File 'lib/rails-crud_actions.rb', line 30 def index end |
#new ⇒ Object
36 37 |
# File 'lib/rails-crud_actions.rb', line 36 def new end |
#show ⇒ Object
33 34 |
# File 'lib/rails-crud_actions.rb', line 33 def show end |
#update ⇒ Object
49 50 51 |
# File 'lib/rails-crud_actions.rb', line 49 def update save_or_render 'edit' end |