ruby-on-rails

uninitialized constant with rails friendships

Hi. I'm new to rails and getting the following error: NameError in FriendshipsController#create uninitialized constant FriendshipsController this also shows up: {"authenticity_token"=>"eQvv3flATE+P1TEErOWP/6fM8dEOIBxltobCxtM/F18=", "friend_id"=>"32"} When I click on the "Add Friend" Link on my users show page. I am following th...

JSP or RUBY/PHP?

At my technologies crossroads and would like to hear some words of wisdom or tales of caution. I am on the verge of assembling a development team and all things are set save my controller layer - which way should I proceed..? I personally am an experienced Java programmer and would certainly never even consider ASP (ever) but, would cert...

How do I troubleshoot errors in Ruby on Rails?

I am trying to get a Rails app working on my web host. Using CPanel, I can create a rails app and I can access the index.html (Welcome aboard) page from my browser. But when I click on "About your application’s environment", it says "We're sorry, but something went wrong." I don't have access to any files on the webserver outside of...

Working with date and time

I have a UTC date of Tue, 16 Feb 2010 03:12:02 UTC +00:00, for example. I want to add 168 hours to this date to get a future UTC date. What's the best way to do that? ...

Improve Controller Performance Ruby on Rails

I have the following code in a controller user = RegUser.create_reg_user(:some_parameters) UserStuff.pass_user(some_parameters) @hex = user.hex The @hex is passed to the view and returned. The UserStuff call is taking a decent amount of time and is not actually important to the @hex which is needed for the view. Is there a way to go...

Is there a Ruby database migration gem, that helps you move content from an old structure to a new structure?

Hi there, Are there any Ruby gems/libraries that help you migrate from an old DB structure to a new structure? ActiveRecord migrations do a good job keeping track of a new db structure, but I wonder if there's something that helps you migrate an entire legacy db to a new structure: transfer_from(:source_table => 'person', :destination_...

Best Resources for Rails Social Networking Friendship

What do you all think are the best resources for adding a "friendship" system to your rails social networking sites? The main three I have found: Self-Referential Associations - Railscast acts_as_network has_many_friends However i find that the railscast one tends to be a bit simplistic, and a lack of implementation documentation for t...

Ruby create an object from a query string

I am using a new Rails project & an old established Oracle db using adapter: oracle_enhanced. Would like to be able to have dynamic searches against the db depending upon what info/field(s) is available to search against. I am trying to get from http://www.abc.com/order/show?acct_num=a123&po_num=789z and create an object such as...

Installing PostgreSQL on OSX for Rails development

I've spent several hours over the past few days trying to get PostgreSQL to play nice with RoR on my Mac. I've followed several tutorials using several different methods such as installing PostgreSQL manually and installing from various 1-click installers However the all the different methods I tried failed on the last step of installi...

what would be my rails URL?

i have a rails app located at [home]/rails_apps/final/final2 on my Bluehosts server. I run script/server here with ssh/shell.. [email protected] [~/rails_apps/final/final2]# script/server -e production => Booting Mongrel => Rails 2.3.4 application starting on http://0.0.0.0:3000 /home/actionen/rails_apps/final/final2/app/cont...

Amazon EC2 instance for Ruby on Rails + Thin + Nginx

Hi, I've been looking for an AMI that has basically an updated version of ruby gems, thin and nginx and mysql installed. EC2onRails seems to be left alone now since Paul decided to leave the project. If you were to deploy your Rails App in the cloud, what are your benchmarks? Recommendations? ...

Using named routes vs. using url_for()

When should one use named routes vs. using url_for with a {:controller => "somecontroller", :action => "someaction"} hash? Is one preferred over the other and why? Is one more maintainable or more efficient w.r.t. performance? ...

subdomain and domain routing

Hi all, I use the subdomain to indicate the product eg. nexusphone.site.com . When a user types in that url I render the product/show view of that product. Users can also use domainnames eg www.nexusphone or nexusphone.com to render that product/show view. www.site.com or site.com should render the home view which explains what my site...

Does rails3 provide any hooks for dropping in pluggable, re-usable components?

What efforts have been made in rails 3 to encourage code re-use? Is there anything akin to merb slices / engines built into the framework that would allow me to drop in a configurable component such as a 'blog' engine? If so, what is considered best practice? ...

How rails render works in controller? Why something it doesn't use layout?

I tried to write render in an action, but layout behavior is different, why? def show # assuming we have a partial in app/views/shared/_panel_show.html.erb #render "shared/_panel_show" # have layout #render "/shared/_panel_show" # without layout #render "shared/panel_show" # Template is missing #render :partial => "share...

Rails: setting column alias attribute with find_by_sql

When I use a column alias in a query with find_by_sql, it doesn't appear to be set in the result objects, even when I add an attr_accessor for the property. class Country < ActiveRecord::Base attr_accessor :average_score def self.sorted_by_average_score sql = "SELECT country_id, AVG(score) AS average_score, countries.name " + ...

How do I validate that two values do not equal each other in a Rails model?

I have a User model, which has an email and a password field. For security, these may not be equal to each other. How can I define this in my model? ...

Rewriting rails url from port 3000?

i have an applicaiton that runs at actionengineers.com:3000. How do i reqwite the application to a subdomain or directory (actionengineers.com/myapp) without disturbing the main site of course. i tried to use .htaccess file but i allways get eror 404. here is the code in the .htaccess file. RewriteEngine on RewriteCond %{HTTP_HOST} ^www...

Shared user table with Authlogic

Hi guys, I'm looking for a solution in order to reuse the user table of another web application that use Authlogic. I'm trying with ActiveResource (in the new app), but I'm missing something. This is the not working code: #Existing app class User < ActiveRecord::Base attr_accessible :username, :email, :password acts_as_authentic...

Conditional value in ruby on rails?

Hello I have a form, in which I can set various client fields like client name client address and more. Only the client name is a must field, and all the other fields can be empty. After saving the client data I display to the end user the clients details page (with all the clients information). Now if the address field is empty I want ...