Archive

Posts Tagged ‘rails’

easy capistrano remote invocation

May 6th, 2009 Comments off

Today I was coding just for fun … and wrote my own Capistrano script for deployment, during this I have found great way to invoke remote tasks.

The method is easy, add following code to your config/deploy.rb file:

set :sudo_call, ''
desc 'makes remote/rake calls to be executed with sudo'
task :use_sudo do
  set :sudo_call, 'sudo'
end

desc 'run rake task'
task :rake do
  ARGV.values_at(Range.new(ARGV.index('rake')+1,-1)).each do |task|
    run "cd #{current_path}; #{sudo_call} RAILS_ENV=production rake #{task}"
  end
  exit(0)
end

desc 'run remote command'
task :remote do
  command=ARGV.values_at(Range.new(ARGV.index('remote')+1,-1))
  run "cd #{current_path}; #{sudo_call} RAILS_ENV=production #{command*' '}"
  exit(0)
end

desc 'run specified rails code on server'
task :runner do
  command=ARGV.values_at(Range.new(ARGV.index('runner')+1,-1))
  run "cd #{current_path}; RAILS_ENV=production script/runner '#{command*' '}'"
  exit(0)
end

Now try your new tool with following commands:

cap rake db:migrate
cap use_sudo rake db:migrate
cap remote "tail -n 10 log/production.log"
cap use_sudo remote cat /etc/passwd
cap runner p User.all
cap runner "User.all.each{ |u| p u }"

In the third call I have used parentheses to hide “-n” form Capistrano, because it is its parameter, to see whole list of Capistrano parameters call it with “cap –help”. For the last command I have used parentheses again because now it contained bash special characters.

Did You liked this post or maybe not, vote on it at dzone.

Categories: Development, Linux Tags: , , , ,

Ruby on Rails application in 10 minutes is a myth

April 2nd, 2009 5 comments

Lately netbeans remainded me about something that makes great marketing for Ruby on Rails – ability to create application in 10 minutes.

By example you can have a look on the netbeans tutorial. Everything looks great, sometimes You can even create the application in 10 minutes …

Lets think what You will get in this 10 minutes:

  • Scaffold of application … without head or legs

Thats all, the application generated in 10 minutes does not have authentication, it does not have administrative part. Of course there is a lot of plugins, that helps to add functionality to Yours application. But wait a minute, authors of this plugins cant catch up stable rails.

Each few months we have new rails version, and each version is requiring application changes, this is endless. After You finish migration to newest rails, after You find new plugins there is new rails version – and the  wheel spins again.

Comparing to other applications rails is getting new releases at least twice offten, that would be good if it would have one stable base, but not, the base is changing each few months.

And what is the plan, four months after rails 2.3 we will have rails 3.0, it will be more like rails or maybe more like merb? Hopefully it will start slowing down a bit, as it requires now very big efforts to maintain application and keep it up todate.

Somebody would say “You can freeze rails, gems and plugins” – yes I can, but I can not freeze my developers, they will learn new rails version, and after one year I will have a team of experienced developers in rails 4.0 or even rails 5.0 and application with frozen reail 2.3 … and try to migrate when the core was rewritten three times during last year.

Assuming having steady framewoirk with “broken tables” like Java or less broken DJango makes a lot more work on begining, but development stacks are available, the documentation is more complete, and the major version changes once for few years, this allows developer to understand and modify application code even after ten years.

Did You liked this post or maybe not, vote on it at dzone.

Categories: Development Tags: , ,

Linux did 1234567890 seconds past 1970′

February 14th, 2009 Comments off

That’s not so important for our development and live,  but as always interesting dates get our attention, todays date will have interesting representation as seconds since start of 1970 year.

1234567890, that showed to me when I have entered the following command and waited a while before  2009-02-14 00:20

while [ $((1234567890 - $(date +%s))) -ge 0 ]; do sleep 1s; clear; date +%s; done

Of course You need to know that Linux is counting time as seconds since begun of year 1970.

Thanks to polish linux blip community for remembering me this very important fact.

Quick update from polish rails blip community, the date for ruby was the same when converting to integer:

irb

Time.now.to_i

Good to hear that not only Linux is affected by this issue.

Categories: Linux Tags: , , ,

NICZ SOFT Rails hosting started

February 12th, 2009 Comments off

Additionally to already started blog hosting we have started a new service – Rails hosting.

Basic Configuration is one instance of rails in passenger, one mysql database, and 500MB disk space limit, everything with ssh access.

Anybody interested should leave a note via one of available contact options.

Categories: Hosting, News Tags: , , , ,

Missing netbeans passenger support – patch ready

February 11th, 2009 Comments off

I have just posted a patch that should enable  passanger support in netbeans, details can be viewed at netbeans issues.

Hope that will be shortly merged and everybody can use it.

I do not even know if this is fully functional, I got cold and had few other tasks on head, but this should be good start point.

Most of the logick required to get it running is already writen, so should be enough.

Categories: Development, Linux Tags: , ,
Get Adobe Flash playerPlugin by wpburn.com wordpress themes