views:

29

answers:

3

Hi 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  A: 

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.

John Drummond
A: 

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

Maletor
A: 

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.