Rails 3 generator's git option? - ruby-on-rails

In rails 2.x I could pass on a --git option to ./script/generate to add files to git automatically after creation. However I have been unable to find such an option (or configuration) in Rails 3.0.
Has this been removed or am I missing something? I tried researching this for a while but I am unable to find any reference.
Thanks,
Prateek

It doesn't have an option like that, although the standard 'rails new' command does generate the .gitignore and .gitkeep files for you.
Otherwise, I think you need to set up the git project yourself.

Related

How can I continue to use Accurev with Capistrano 3?

We use AccuRev (and I cannot change that) and have been deploying with Capistrano 2. I need to upgrade to Capistrano 3, but it seems that the Accurev SCM module has been removed. Is there a way I can continue to use AccuRev and deploy with Capistrano 3?
deploy.rb piece
set :scm, :accurev
Deployment error
cap aborted!
LoadError: cannot load such file -- capistrano/accurev.rb
As Capistrano3 documentation says - there is only git, hg and svn support.
But it should not be so hard to port old accurev module from Capistrano 2 to Capistrano 3. Some classes changed but core is same - functions have to return proper commands with proper parameters.
You can start from git implementation from master and replace it with AccuRev.
The workaround I am using since one year is the following:
1- Edit the file capistrano-3.3.5/lib/capistrano/setup.rb and replace
load "capistrano/#{fetch(:scm)}.rb"
by
load "#{fetch(:scm_path, 'capistrano')}/#{fetch(:scm)}.rb"
2- Add in your config/deploy.rb file
set :scm_path, 'path/to/accurev/directory'
That will give to capistrano a chance to open the configuration schema of accurev. Note that capistrano v3 changed its syntax, and you may have to modify accurev files (I suggest then to duplicate them in your lib folder).
It's ugly to edit the gem file content directly, but there is no other way here. You can also fork their git and do the modification on your fork if you like.
I have a similar problem because I am using custom-made scm in capistrano. Tried to get them to accept a pull request to add this scm_path configuration option since last year but they refuse, saying that they will migrate to something better soon ...

How would I change the rails project directory?

I am using Ruby on Windows and when I use rails to create a project it puts the folder in my user directory, I'd like to specify another location. How would I do this?
You can specify a full path when you say rails new:
> rails new /some/path/where/you/want/your/app
That should work in Windows just like everywhere else.
You can always say rails --help or rails command --help to get some quick help on using the rails command.
use cd to move to the directory you want it in before generating the project.

Rails and Rake : .rakeTasks?

What is .rakeTasks file for ?
Rails version : 3.2.1
The .rakeTasks file is created by the IntelliJ IDEA Ruby plugin (and possibly by JetBrains' Ruby-specific RubyMine IDE as well, I'm not sure). As the comments in the file itself state:
<!--This file was automatically generated by Ruby plugin.
You are allowed to:
1. Remove rake task
2. Add existing rake tasks
To add existing rake tasks automatically delete this file and reload the project.
-->
It provides the list of Rake tasks that appears when you select Tools / Run Rake Task...:
Unless you need to customize that list for some reason, you probably never need to edit the file. Personally I exclude it from version control in my .gitignore, along with the .ipr, .iml, and .iws files. (I might check it in if I was working in a homogeneous IDEA shop, but I'm not.)
This file are auto-require and define you project specific task accessible by rake.

Why does rails ignore .bundle by default?

Isn't the point of the project .bundle/config to specify config that is relevant to the project?
On the bundle-config manpage is says:
This command allows you to interact with bundler's configuration
system. Bundler retrieves its configuration from the local application
(app/.bundle/config), environment variables, and the user's home
directory (~/.bundle/config), in that order of priority.
So ensure that you don't have any configuration files that are taking priority over the one you want to use.
You can configure this file yourself or set options using bundle config (option), running bundle config without any options prints the current configuration.
For example you can set compile time options for they mysql gem like so:
bundle config build.mysql --with-mysql-config=/usr/local/mysql/bin/mysql_config
So yes, app/.bundle/config is used to set bundle options for the current project.
Edit:
This change was added in commit efa85055 to the Rails github repo. You can view that version of the file here and the commit here.
The commit message is from José Valim and mentions the line you have a question about:
Make bin/rails call rails/commands/application, fix generators usage
and update .gitignores.
Edit Again:
This is a quote from bundler on why you should not check the .bundle directory into any VCS.
Do not check in the .bundle directory, or any of the files inside it.
Those files are specific to each particular machine, and are used to
persist installation options between runs of the bundle install
command.

Ruby on Rails config.secret_token error

I just started learning ruby on rails.
I followed a lot of install examples, but when i ran the example am getting this error
A secret is required to generate an integrity hash for cookie session data. Use config.secret_token = "some secret phrase of at least 30 characters"in config/initializers/secret_token.rb
I search for it but i dont see too much help.
plz help.
Platform: Mac OS X.
The easiest way to generate a new secret token is to run
rake secret
at the command line.
Your token should have been generated automatically by Rails, but you could still use something like:
irb(main):007:0> "#{ActiveSupport::SecureRandom.hex(64)}"
=> "921b00fcfabe0368d70627020f3b4c969cfd9bdc2474f4040c1ae976f687014694beb5d36dfc0c41bac8ebde96a14fceaee228d6e34d8183c5d7cc99d310d4f9"
meaning, you can generate some random string and put it into your config/initializers/secret_token.rb file:
# Be sure to restart your server when you modify this file.
Yourapp::Application.config.secret_token = '921b00fcfabe0368d70627020f3b4c969cfd9bdc2474f4040c1ae976f687014694beb5d36dfc0c41bac8ebde96a14fceaee228d6e34d8183c5d7cc99d310d4f9'
This is an issue with rails version probably. I had this issue when I uninstalled Rails 4 and installed Rails 3. After checking rails -v and seeing that it was indeed Rails 3, I executed rails new myapp. For some reason the configuration file config/initializers/secret_token.rb had the "config.secret_key_base" variable defined, which appears to be how Rails 4 does it. I was able to fix it by changing it to "config.secret_token", which I believe is what Rails 3 uses.
This simple command worked for me :
rvmsudo rake generate_secret_token
Make sure you have this in your environment.rb:
YourApp::Application.initialize!
Ran into this same issue and found out my config/initializers/secret_token.rb file was being ignored by git in my .gitignore file. Check out the config/initializers directory in your git source location and make sure the secret_token.rb file exists. If it doesn't edit your .gitignore file so that git will not ignore the secret_token.rb file and commit your changes (usually hidden - I used these simple commands to display hidden files on a mac http://osxdaily.com/2009/02/25/show-hidden-files-in-os-x/).

Resources