lib/rails/generators/humdrum/resource/templates/controllers/resource_controller.rb in humdrum-rails-0.0.8 vs lib/rails/generators/humdrum/resource/templates/controllers/resource_controller.rb in humdrum-rails-0.0.9

- old
+ new

@@ -1,13 +1,11 @@ class <%= controller_class %> < ApplicationController - #before_filter :require_user, :set_navs, :parse_filters_from_url - layout "public" + #before_filter :require_user #authorize_actions_for Item, :actions => {:index => :delete} + before_filter :set_navs, :parse_pagination_params, :only=>:index - before_filter :parse_pagination_params, :only=>:index - # GET /<%= instances_name %> # GET /<%= instances_name %>.js # GET /<%= instances_name %>.json def index @@ -103,11 +101,11 @@ def update ## Fetching the <%= instance_name %> @<%= instance_name %> = <%= model_class %>.find(params[:id]) ## Updating the @<%= instance_name %> object with params - @<%= instance_name %>.update_attributes(params[:<%= instance_name %>]) + @<%= instance_name %>.assign_attributes(params[:<%= instance_name %>]) ## Validating the data @<%= instance_name %>.valid? respond_to do |format| @@ -179,11 +177,11 @@ def get_collections # Fetching the <%= instances_name %> relation = <%= model_class %>.where("") @filters = {} - if params[:<%= instance_name %>] && params[:<%= instance_name %>][:query] - @query = params[:<%= instance_name %>][:query].strip + if params[:query] + @query = params[:query].strip if !@query.blank? relation = relation.where(" <% string_fields_including_main_field.each_with_index do |sfield, i| -%> <% if string_fields_including_main_field.size - 1 != i -%> LOWER(<%= sfield %>) LIKE LOWER('%#{@query}%') OR\