Tuesday, August 18, 2009

Rails IDE: Programming a Rails Project Using Aptana Radrails (Updated 11th Jan 2017)

Update on 11/1/17 : Aptana Rdrails does not work with Rails 5

Here are the steps that I took when programming a RoR project using Aptana Rails 1.5 on Ubuntu 9.04

1. Use MySQL Administrator to create a new database crm2009
2. Use Aptana Radrails(defaulted to Radrails perspective) to create new project via
a) File
b) New
c) Rails Project
and the standard Rail Page was launched apparently without any error

d) Checked Console and found the folowing error message
/!\ FAILSAFE /!\ Tue Aug 18 18:03:01 +0800 2009
Status: 500 Internal Server Error
Access denied for user 'root'@'localhost' (using password: NO)

3. Edited config\database.yml to put in mysql password and the problem went away


Installing Rails Plugin

The problem with Aptana Radrails is that being Eclippse 3.2-based, it does not support installing from the github although using the Rails Plugin Tab works with svn. Worst still, using console script/plugin install also does not work :-(

So what's the workaround ?

Opening a Terminal Window, i was force to type
git clone to download to
crm2009\vendor\plugins

In this manner, I installed restul_authentication,role_requirement,acts_as_audited,active_scaffold etc

Then, I selected vendor\plugins and right-clicked to Refresh and the desired plugins are now in the Ruby Explorer


Installing restful_authentication
a) Select Generate Tab
b) Select authenticated
c)Type user session in parameters
d) Click OK

In the Console, we can see this

script/generate authenticated user sessions
Ready to generate.
----------------------------------------------------------------------
Once finished, don't forget to:

- Add routes to these resources. In config/routes.rb, insert routes like:
map.signup '/signup', :controller => 'users', :action => 'new'
map.login '/login', :controller => 'sessions', :action => 'new'
map.logout '/logout', :controller => 'sessions', :action => 'destroy'

----------------------------------------------------------------------

We've create a new site key in config/initializers/site_keys.rb. If you have existing
user accounts their passwords will no longer work (see README). As always,
keep this file safe but don't post it in public.

----------------------------------------------------------------------
exists app/models/
exists app/controllers/
exists app/controllers/
exists app/helpers/
create app/views/sessions
exists app/controllers/
exists app/helpers/
create app/views/users
exists config/initializers
exists test/functional/
exists test/functional/
exists test/unit/
exists test/fixtures/
create app/models/user.rb
create app/controllers/sessions_controller.rb
create app/controllers/users_controller.rb
create lib/authenticated_system.rb
create lib/authenticated_test_helper.rb
create config/initializers/site_keys.rb
create test/functional/sessions_controller_test.rb
create test/functional/users_controller_test.rb
create test/unit/user_test.rb
create test/fixtures/users.yml
create app/helpers/sessions_helper.rb
create app/helpers/users_helper.rb
create app/views/sessions/new.html.erb
create app/views/users/new.html.erb
create app/views/users/_user_bar.html.erb
create db/migrate
create db/migrate/20090818114130_create_users.rb
route map.resource :session
route map.resources :users
route map.signup '/signup', :controller => 'users', :action => 'new'
route map.register '/register', :controller => 'users', :action => 'create'
route map.login '/login', :controller => 'sessions', :action => 'new'
route map.logout '/logout', :controller => 'sessions', :action => 'destroy'
>

Then, select db/migrate/yymmddhhmmss_create_users.rb
Right-click, select Rake/db/migrate and hit enter an in the Rails Console

rake db:migrate
== CreateUsers: migrating ====================================================
-- create_table("users", {:force=>true})
-> 0.0108s
-- add_index(:users, :login, {:unique=>true})
-> 0.0122s
== CreateUsers: migrated (0.0246s) ===========================================

>

script/generate mailer user
exists app/models/
create app/views/user
exists test/unit/
create test/fixtures/user
overwrite app/models/user.rb? (enter "h" for help) [Ynaqdh] Y
force app/models/user.rb
overwrite test/unit/user_test.rb? (enter "h" for help) [Ynaqdh] Y
force test/unit/user_test.rb

Installing role_requirement

script/generate roles Role User
Generating Role against User
Added the following to the top of app/models/user.rb:



# ---------------------------------------
# The following code has been generated by role_requirement.
# You may wish to modify it to suit your need
has_and_belongs_to_many :roles

# has_role? simply needs to return true or false whether a user has a role or not.
# It may be a good idea to have "admin" roles return true always
def has_role?(role_in_question)
@_list ||= self.roles.collect(&:name)
return true if @_list.include?("admin")
(@_list.include?(role_in_question.to_s) )
end
# ---------------------------------------




Added ApplicationController include to /home/chee/Aptana Studio Workspace/crm2009/app/controllers/application_controller.rb
Added RoleRequirement include to /home/chee/Aptana Studio Workspace/crm2009/app/controllers/application_controller.rb
create test/fixtures/roles.yml
create app/models/role.rb
create lib/role_requirement_system.rb
create lib/role_requirement_test_helper.rb
create lib/hijacker.rb
exists db/migrate
create db/migrate/20090818131928_create_roles.rb
>

Then, select db/migrate/yymmddhhmmss_create_roles.rb
Right-click, select Rake/db/migrate and hit enter an in the Rails Console


rake db:migrate
== CreateRoles: migrating ====================================================
-- create_table("roles")
-> 0.0652s
-- create_table("roles_users", {:id=>false})
-> 0.0066s
-- add_index("roles_users", "role_id")
-> 0.0123s
-- add_index("roles_users", "user_id")
-> 0.0486s
== CreateRoles: migrated (0.1342s) ===========================================

>

More to come...

No comments:

Welcome to Rails.. Rails... Rails !

In 1995, I started the popular Clipper...Clipper... Clipper website (no blogs then) which was very popular and linked by virtually every Clipper-related site. When I switched to Windows via Delphi in 1997, I started the Delphi... Delphi... Delphi site. In June 2007, I discovered Ruby on Rails and no prize for guessing what I am gonna name this blog. which I started on 2nd October 2007.

As at 10th June 2010, we have 13,364 unique visitors from more than 84 countries such as Angola, Andorra, Argentina, Australia, Austria, Algeria,Barbados, Bosnia and Herzogovina, Belgium, Brazil, Bulgaria, Bangladesh, Belarus, Bolivia, Chile, Cambodia, Cape Vede, Canada, China, Colombia, Costa Rica, Croatia, Cyprus, Czech Republic, Denmark, Egypt, Estonia, Finland, France, Guadeloupe, Guatemala, Germany, Greece, Hong Kong, Hungary, India, Indonesia, Ireland, Israel, Italy, Japan, Kenya, Korea, Lithuania, Latvia, Malaysia, Mexico, Macao, Netherlands, Nepal, Norway, New Zealand, Oman, Panama, Peru, Poland, Portugal,Paraguay , Philippines, Romania, Russian Federation, Saudi Arabia, Singapore, Spain, Slovakia, Slovenia, Serbia, South Korea, Slovenia, South Africa, Spain, Switzerland, Sri Lanka, Sweden, Taiwan, Thailand, Turkey, United Arab Emirates, Ukraine, USA, UK, Venezuela, Vietnam

CCH
10th June 2010, 19:42