Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

ruby - nested forms for 2 models in rails using dm-accepts_nested_attributes and dm-is-tree -


i have 2 models: post , image in forum application posts arranged in parent-child format using dm-is-tree. point, images had been part of post model. post model gets unwieldy , need add more depth notating image, i'm working spin off image own model, still part of post in output.

so started integrating dm-accepts_nested_attributes in simple arrangement:

class post   include datamapper::resource    property :id, serial                                        property :istop, string                                      property :created_at, datetime                               property :updated_at, datetime                               property :content, text                                       has n, :images                                              accepts_nested_attributes_for :images                        :tree, :order => [:istop, :created_at]  class image    include datamapper::resource    property :id, serial   property :created_at, datetime    belongs_to :post    property :image, string, :auto_validation => false        # carrierwave image info   mount_uploader :image, imageuploader                      # carrierwave uploader 

i have form(haml) on every page creating post:

 = form_for [@forum,post.new], :html => {:multipart => true} |f|   = f.hidden_field :istop, :value => "parent"   = f.text_area :content   = f.fields_for :simages_attributes |g|    = g.file_field :image   .actions    = f.submit 

that goes controller:

def create     @forum = forum.get(params[:forum_id])     @post = @forum.posts.create(params[:post])      respond_to |format|       if @post.save         format.html { redirect_to(forum_path(@forum), :notice => 'post created.') }       else         format.html { redirect_to(forum_path(@forum), :notice => 'there error in posting') }       end     end   end 

the error when posting:

undefined method[]' #`

, nomethoderror

i'm not sure i'm doing or coming @ point. i'm not sure if have form set-up correctly (i've been following similar active record tutorials , haven't delved dm-accepts_nested code @ yet). i'm able set more basic stuff through command line, not images. understand basics of nesting, not how integrate i'm doing atm.

maybe knows. appreciated.

attr_accessor :images_attributes in post model, allows form submit

however, image not being saved, i.e. gets lost somewhere , isn't saved


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -