0

I am trying to create a ruby on rails app to capture data from form and create a corresponding XML.I have created a dummy model class which is not extending active record

Do i have to do that .Below is the code and the error i m facing plz help

  class RamOne
    attr_accessor :name,:city
   end

Controller

       def start
        @ramone = RamOne.new
                end

    def load_new
        @ramone = RamOne.new(params[:ramone])
        if @ramone.save
           redirect_to :action => ‘gen_xml’
        end
    end

    def gen_xml
            @xml = Builder::XmlMarkup.new
            @ramones = RamOne.find(:all)
            render :layout => false
    end

View captures name,city and has a submit action attached with load_new

error : wrong num of args(1 for 0 ) in load_new what is wrong?

1
  • Why no ActiveRecord? What do you expect the save, find calls to do? Commented Aug 15, 2010 at 19:17

3 Answers 3

1

You can't call RamOne.new with an argument because your RamOne class does not override the initialize method. Also, @ramone.save and RamOne.find are all ActiveRecord methods, so I think you need to extend ActiveRecord::Base in your RamOne class.

Sign up to request clarification or add additional context in comments.

Comments

0

Check out the Hpricot gem http://hpricot.com/ if you are doing some heavy duty XML.

Check out REST to clean up your controller. http://guides.rubyonrails.org/routing.html#restful-routing-the-rails-default

Comments

0

Can i get rid of the model class

and store my captured data in a normal ruby class and fetch from it to create the xml .Are there any helper methods available

similar to form_for() helper

<% form_for :ramone, @ramone, :url => { :action => "load_new" }, :html => { :method => :get } do |f| %>

can i find any other non ActiveRecordHelper methods

I dont want the Model class unnecesarily.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.