1. You have to create controllers with the class names and then you can copy the code in the controllers. 2. You can create a model and a database with all the fields you want and then you can insert the data in the db from the variables using a controller.
I am also a beginner at Rails. So, please confirm this with someone else as well. Happy coding! On Mar 28, 11:23 pm, Derek Cannon <[email protected]> wrote: > (First, I'm very new to Rails and still slightly new to Ruby. So bare > with me.) > > I made a Ruby application that allows me to view local XML files which > contain information on my favorite movies. My program reads the XML > files and loads them into variables (such as @title = "The Terminator, > @year = "1984", etc). All of this is done in a class called Movie, so I > get all the XML files from a directory, then create an array of Movie > classes which all hold the information for their specific XML file. > > (For the visual thinkers, that's: my_dir.each { |i| > my_array.push(Movie.new(i)) }) > > Everything works fine, and I can organize the data however I please. > > But now that I'm getting started with Rails, I'd like to create a > controller that -- instead of displaying the movie information to the > console -- would write these variables into a SQLite3 database. I've > looked around, and I've already got the database set up, and with > Scaffolding, I can add/edit/remove entries manually, but I'm still > unsure of how to: > > 1. Copy/paste my Ruby code into my Rails project. (Does the class I've > created simply go into a new controller, or is there some other > convention for where to put complete Ruby classes?) > 2. How to add the variables directly to the database, so I don't have to > manually enter the data. > > If anyone could help me with this, I'd greatly appreciate it. If you're > curious as to my level of knowledge in Rails, the only things I have a > fairly good grasp on are: how to start a server, how to view the pages > on the server, how to create a database (with all the tables I need), > how to create a scaffolding, and what the difference is between > controllers and the actual view page. > -- > Posted viahttp://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

