ruby - Heroku Production Rails(3.2.3) Active admin(0.5) NoMethodError in create & update -
as working on active admin(0.5) rails 3.2.3 using multilingual support using globalise 3 .
when running application on local under development & production environment works great.
but when deployed on heroku production mode throwing me error same code using on local.
when click on create new page giving me below error:
nomethoderror in admin::hometemplatescontroller#new undefined method `build_app_page' nil:nilclass rails.root: /app application trace | framework trace | full trace app/admin/home_templates.rb:16:in `new'
please find below code
activeadmin.register hometemplate menu false config.clear_action_items! form :partial => "form" controller protect_from_forgery :except => :sort def new # @home_template =hometemplate.new # if !!current_ability.attributes_for(:create, hometemplate)[:app_instance_id] # @valid_parents = apppage.where("app_instance_id = ? , parent_id null", current_ability.attributes_for(:create, hometemplate)[:app_instance_id]) # end @home_template.build_app_page end def create # if !!current_ability.attributes_for(:create, hometemplate)[:app_instance_id] # @valid_parents = apppage.where("app_instance_id = ? , parent_id null", current_ability.attributes_for(:create, hometemplate)[:app_instance_id]) # end if @home_template.present? @home_template.app_page.protected = false; @home_template.app_page.hidden = false; @home_template.app_page.app_instance = @home_template.app_instance; create! end end def update #@home_template = hometemplate.find(params[:id]) @valid_parents = apppage.where("app_instance_id = ? , parent_id null", @home_template.app_page.app_instance_id) update! end def edit # if !!current_ability.attributes_for(:edit, hometemplate)[:app_instance_id] # @valid_parents = apppage.where("app_instance_id = ? , parent_id null", current_ability.attributes_for(:edit, hometemplate)[:app_instance_id]) # rails.logger.info( @valid_parents) # rails.logger.info( current_ability.attributes_for(:edit, hometemplate)[:app_instance_id]) # end rails.logger.info( "home template outside") #@home_template = hometemplate.find(params[:id]) @valid_parents = apppage.where("app_instance_id = ? , parent_id null", @home_template.app_page.app_instance_id) rails.logger.info(@valid_parents) end end collection_action :sort, :method => :post if(params[:ids]) params[:ids].each_with_index |id, index| app_page = apppage.find(id) app_page.move_to_child_of app_page.parent_id if can? :update, app_page.templatable end end head 200 end end
i tried connect console through heroku & fetching models.
i checked postgres database on local in production ode & worked charm.
right using sqlite & postgres on local & heroku postgres.
your & guidance highly appreciable & deserves hat off side.
please let me know if more details required.
right using polymorphic association
as below
class hometemplate < activerecord::base include belongstoappinstance has_one :app_page, :as => :templatable has_many :home_banner_images, :dependent => :destroy accepts_nested_attributes_for :home_banner_images, :allow_destroy => true accepts_nested_attributes_for :app_page validates_presence_of :app_page end
apppages as:
class apppage < activerecord::base include belongstoappinstance belongs_to :last_modified_by, :class_name => "adminuser" validates_presence_of :last_modified_by belongs_to :templatable, :polymorphic => true, :dependent => :destroy has_many :app_page_callouts acts_as_nested_set attr_readonly :hidden attr_readonly :protected default_scope :order => 'lft asc' validates_presence_of :name #validates_uniqueness_of :name, :scope => :app_instance_id validates_uniqueness_of :app_page_role, :scope => :app_instance_id mount_uploader :related_pdf, pdfuploader validate :parent_must_belong_to_same_app_instance #validates_inclusion_of :linked_model, :in => apppage.allowable_linked_models, :unless => proc.new {|app_page| app_page.linked_model.blank? } attr_accessible :name,:subtitle,:body,:app_page_attributes, :app_instance_id,:app_page_role,:related_pdf, :parent_id,:translations_attributes, :last_modified_by,:app_instance,:sort,:view_controller,:hidden,:protected,:app_page_callouts,:parent active_admin_translates :name,:subtitle,:body #validates_globalized_uniqueness_of :name,:scope => :locale def parent_must_belong_to_same_app_instance if !self.parent_id.nil? && self.parent.app_instance_id != self.app_instance_id errors.add(:parent_id, "the parent must belong same app instance.") end end def set_view_controller if self.view_controller.nil? self.view_controller = "detail" end end end
Comments
Post a Comment