English 中文(简体)
How to import existing ROR project?
原标题:

I m new to Ruby on Rails (PHP developer here) and I need to edit an existing ROR project. I ve been using Aptana Studio for my PHP projects (switched to Zend after Aptana 2.0) but I ve kept Aptana RadRails for my ruby projects.

So what I want to do is to get the ROR project from the server (it s hosted on some linux machine) and import it into RadRails for local development. I ve downloaded the files from the server and imported them in a new RadRails ROR project but it doesn t work as intended. Is there anything else I should do ? I ve read about freezing the gems , switching to production mode and dumping the database for a ROR project upon releasing. Are there some steps needed to undo those operations ?

UPDATE: The problem that I m having is that I get various errors when trying to visualize in the browser the pages for different controllers.

ActionController::InvalidAuthenticityToken in 
No :secret given to the #protect_from_forgery call.  Set that or use a session store capable of generating its own keys (Cookie Session Store).

OR

no such file to load -- xml
This error occurred while loading the following files:
   hotels_pro
   xml

This leads me to believe that (maybe) I haven t got all the files. On the other hand I have double-checked and I have all the files from the server.

Thanks,

问题回答

A RoR application is more than just the sum of its source files. There s also the database, gems and a server which exist outside the project directory. Without knowing exactly what doesn t we can only speculate which is causing you problems. Being new to Rails, it s probably all of them. If after all this you re still not up and running a few rounds of "Google the Error" should fix you up.

You ll need to set these things up in your development environment before you can proceed. The following assumes you have a working ruby environment: rubygems installed with the rails, and rake gems. Note any commands and paths that follow are relative to the root of your rails project.

Database:

  • Start with editing config/databases.yml to find out which database your app will try to connect to. Change it if necessary so it names a local database. Create that database, if it doesn t exist with $rake db:create

  • If you need existing data to test with you can take a dump from your production database and import it into your working database. How to do this is dependent on the type of database in question. Otherwise you can run the migrations with $ rake db:migrate to produce your development database (assuming the previous developer designed the database with migrations.)

Gems:

  • Check the config/environment.rb, for your list of required gems. Install all these gems if they haven t been already.

  • If you re using Rails 2.1 or newer, you can streamline this process by ensuring that all gems are required using the newer config.gem this_gem form instead of older require this_gem declaration. Once all required gems are in this form, you can use $ rake gems:install && rake gems:build to ensure they re all installed.

Server:

Is pretty trivial, all rails instalations come with web brick which is fine for development. But mongrel is also suitable.

P.S. If you re not using some kind of revision control it s strongly advised to set something up before starting. It s not a requirement, but it will likely save your ass at some point.





相关问题
rails collection_select vs. select

collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...

SSL slowness in EC2

We ve deployed our rails app to EC2. In our setup, we have two proxies on small instances behind round-robin DNS. These run nginx load balancers for a dynamically growing and shrinking farm of web ...

Auth-code with A-Za-z0-9 to use in an URL parameter

As part of a web application I need an auth-code to pass as a URL parameter. I am currently using (in Rails) : Digest::SHA1.hexdigest((object_id + rand(255)).to_s) Which provides long strings like : ...

RubyCAS-Client question: Rails

I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?

activerecord has_many :through find with one sql call

I have a these 3 models: class User < ActiveRecord::Base has_many :permissions, :dependent => :destroy has_many :roles, :through => :permissions end class Permission < ActiveRecord::...

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

Text Editor for Ruby-on-Rails

guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...

How to get SQL queries for each user where env is production

I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: ...

热门标签