What is the Pylons equivalent of Django's 'syncdb'? - pylons

Short and sweet question:
I've inherited a Pylons site with a bunch of models. If it was Django I would simply run 'syncdb' to set up a local database. What is the equivalent in Pylons?

Maybe you're looking for paster setup-app development.ini (replace development.ini with your actual configuration file).
This will go through your websetup.py file, which should create your tables if the project was started answering True to the question about using SQLAlchemy.

Related

What file runs everything on the ruby server?

I am new to rails and ruby and I wanted to make a small web app using a rails backend (not a good idea considering I am new to both). I am trying to conceptualize the folder structure of rails, and I am confused whether there is a file that runs everything in the folder.. or how does it work? I've used node.js and django (python) and usually I'll have a server file that imports my database and such, but with this rails setup--I am a bit overwhelmed. Any help would be great!
In your rails app, there is no one file that requires and runs all other files. There are a couple of files that do something like this, but they don't load everything.
Instead, rails knows where to look for information when it boots your app. Your database configuration goes to config/database.yml. Boot-time setup goes to config/initializers/. And so on. As a rails dev, you're expected to know this. Convention over configuration, they call it.
A good rails book can help with learning these conventions (what goes where).

Is it possible to create a self contained ruby on rails package?

I'm currently looking into what language to build a web application on that will be sold to companies. To make things easier, I was hoping to package the webapp into a convenient installer that contains the entire stack which will run automatically.
Is there any way to create a self contained RoR package?
The only project I'm aware of is called pkgr, which bundles an entire rails app into a DEB package. So if you don't mind limiting your installs to Ubuntu/Debian, you could give it a try.
pkgr home page
Github
You can write a rake task to automatize everything for you. Migrations, bundling, enviroment setup. And it's pretty much plain Ruby, too.
In the end it would be just running a script file to do the job.

A Ruby On Rails-like migration tool

I like that Ruby On Rails allows you to write a simple schema in which you can create and update a database using. Is there any tool like Ruby On Rails's migration, as I would like to use the method without using Ruby On Rails for my website development?
There's no reason you can't use ActiveRecord::Migration outside of a rails app. In fact, you'll find plenty of examples of people doing this, as in http://exposinggotchas.blogspot.com/2011/02/activerecord-migrations-without-rails.html
If you're using mongo as the persistent store, check out mongrations for this.
I have heard this week on a little conference a talk about a tool called Liquibase, a database change management tool. It is based on Java (I think), but manages the database migrations in an XML file. The change sets you have to write are similar to the migrations you can write with Rails. If you use Liquibase inside an IDE like Eclipse, you get completion for all relevant parts of the change sets. It supports a lot of databases out of the box, so it could be an alternative, especially that nowadays Java is installed everywhere.
I recommend Python Alembic. It's not Ruby though.

With rails.vim, why don't commands work when the active buffer is empty or not a file that's part of a rails project?

If I don't have a file open from the rails project I'm working on, I can't use any rails.vim commands such as :Rcontroller, :Rmodel, :Rview (I get the error: Not an editor command).
Additionally, if i try to use :Rconfig or :Rroutes when I don't have a rails file open, I get the error: Not an editor command: :Rfind application.yml.
I'm using a pre-fab vim config so I am guessing I need to hunt down an issue in there? Or is this just the way rails.vim is meant to work?
The short answer is that this is the way rails.vim works.
rails.vim tries to detect the Rails project using the path of the current buffer. In general this makes sense because a number of the commands provided by rails.vim are specific to the current file. Also, it is very possible to open files from several Rails projects in the same Vim session, so even commands that only reference the project as a whole need to be tied to the current context.
It would be nice if the project-level commands like you describe could be available when you're in a new buffer by falling back to getcwd() and detect that the current working directory is a Rails application. But from a cursory examination of the source, I think it would require some significant restructuring of the plugin.
I wrote a plugin called Open that opens up a project using NERDTree and project the README as a default view. One of the advantages of this is that by having a file open by default, you can use any of the Rails commands immediately.

How go about writing standalone Ruby ActiveRecord utility in my current rails project?

I have a RoR project on my Windows 7 PC.
I want to create some Ruby code that I can execute from the cmd.exe command line that manipulates the development database (via database.yml) of the project. (I don't want to have to run my utility code via a web page.)
What is the best way to go about pulling this off? (I'm a newbie.)
I can't put the code in the test/ directory because that executes against the test database.
I tried just creating a utility.rb file under app/ but when I run it I get this:
utility.rb:5: uninitialized constant ActiveRecord (NameError)
My standalone file obviously doesn't know about the rest of the rails framework.
Any suggestions?
Rails comes with a utility to do exactly this. Instead of using ruby filename, use script/runner filename (from within the top-level directory for the Rails project), which will automatically load up your Rails environment before running the script.
However, if what you're trying to do is manipulate the database, the right answer is probably to create a migration. Most people assume that migrations are only for changing the structure of your database (adding or removing columns or tables) but they can also be a great way to add seed data or manipulate all the data in the database.
You can write your own rake task which depends on :environment and pass RAILS_ENV=development when executing it.
Nice screencast about it: screencast

Resources