ruby-on-rails

capistrano password prompt

Capistrano keeps asking me for password for every deplyoyment. How do I not let it happen? ruby version 1.8.7 REE capistrano version 2.5.19 Here is my capfile and directory permissions. http://pastie.org/1189919 Everything up-to-date ** transaction: start * executing `deploy:update_code' updating the cached checkout on all s...

ruby on rails custom setter help

Hello, sorry for my english, I have a model named Recipe and Recipe has an attribute named duration In my form, I have 2 dropdowns to get duration attribute select_tag 'duration[hours]' select_tag 'duration[minutes]' I need the value of duration attribute like this format hh:mm:ss I have tried with def duration=(d) self.duration...

Playing with Scrapi in Rails 3.. getting Segmentation Fault error / Abort Trap

What I've done so far.. sudo gem install scrapi sudo gem install tidy This didn't work because it didn't have the libtidy.dylib So I did this : sudo port install tidy sudo cp libtidy.dylib /Library/Ruby/Gems/1.8/gems/scrapi-1.2.0/lib/tidy/libtidy.dylib Then I started following the simple railscast at : http://media.railscasts.co...

rails console - display active record results in a table

Is there a way to display Active Record results in table format in the script/console environment? ...

Capistrano Permission/Users/SSH/Git

I think I need to understand this from the basic level. Form what I know so far it seems, there are a few user account involved in deploymnent 1 - Deployer user for capistrano 2 - www-data account (not sure exactly what this does) 3 - the git user What do .. 1 - each of these users do? 2 - what permissions they need onthe productio...

Update a String Attribute in Rails

I am trying to update a string attribute in the database. I tried using update_attribute but it isn't working. It works for integer attributes but not for String attributes. How do i solve this ? EDIT code example: @post = Post.find(params[:post_id]) @comment = @post.comments.create!(params[:comment]) @comment.update_attribute(:comm...

Gem dependency issues

Let us say there are two gems A ( depends on gem C version 2) B ( depends on gem C version 1) My rails application requires gem A, and B. How do you handle the collision of two versions of the gem C while loading A and B. ...

Store array in database using Ruby on Rails

ive got an array that has three values; crime, drama, thriller. Im trying to loop through each value and save it to the database. How do i extract a name from the array and save it in the database. ...

Devise Custom Routes and Login Pages

I'm trying to get Custom Routes working in my Rails application (Ruby 1.9.2 with Rails 3). This is my config/routes.rb file match '/dashboard' => 'home#dashboard', :as => 'user_root' devise_for :user do get "/login", :to => "devise/sessions#new" # Add a custom sign in route for user sign in get "/logout", :to => "devise/sessions#...

Need Recommendations for Twitter and Facebook Gems

Hi, I'm building an app in Rails 3. I currently have a user model which is authenticated via devise (email + password auth). I want to be able to show connect to facebook, connect to twitter buttons to the users once they are logged in. After obtaining the keys from Facebook and Twitter, I'd want to store it in the database for futur...

CSS Sprite generator for Ruby on Rails project

I'm currently working on a large, highly trafficked Ruby on Rails website and in order to get our page load times down, we are looking at spriting our background images. There seem to be a lot of tools out there but many are in the early stages of dev and many don't support some of the features we need. Features which are important to ...

How do you install Ruby on Rails plugins?

I am trying to install the has_calendar plugin, and it says that is successfully installing. However, when I have a page with code the plugin should execute, I am returned errors of undefined functions. Is there somewhere I need to reference the plugin as a helper? Here the sample code, straight off the wiki page. <%= calendar :year =...

Add seconds (in fixnum format) to a datetime, Rails

I need to pass a variable to my view with Time.now + @seconds in time format (i.e. 12pm + 3600 seconds = 1:00pm, which goes to the view). Time.now + @seconds #seconds is a fixnum doesn't work because "Time can't be coerced into Fixnum". How then can I generate this simple result? ...

Rails 3 - Looping through DB records, one record has a HASH

Given a database with records like the following Table: AuditLog Fields: ID | USERID | TYPE | TIME | DATA id:1, userId:1, type:PHOTO, time:2008-10-15 12:00:00, data:{photoId:2089, photoName:A trip to the beach} Lets say the database had 50 records, with Rails How can I loop through the results as follows: id, user_id, data.photoI...

How do I create a Up/Down voting system like stackoverflow?

Hey guys, I'm making a site in Rails, and I want to add a vote up/down system like here in Stackoverflow. Can anyone suggest how to do it? I do know that I'll enter each vote into the database, but I mean, how do I code the vote buttons? What will I use, can anyone help me. Ajax isn't required but it would be nice. I was going to try t...

Two Separate Navigations on a Single Rails Page

I'm creating a rails app with two columns. On one side is a journal log and the other is a set of various links and resources to internal pages. I'd like to be able to navigate to different pages of the journal log on the left side without changing the content on the right. I'd also like to navigate through pages on the right without cha...

Rails 3 Case Statement in a View

Hello... I have an AuditLog with things like id | action | type | description... What I'd like to do in the View is something like Case description when "created" created styling when "deleted" deleted styling else error end Trying to learn how to do this in a view and the correct syntax, which the resources I found ...

Submitting an array with form_for

Is there a way to submit an array using 'form_for'? Here's an example of what I mean if I used regular html to pass the values: <input type="text" name="product[cost][]"> Which should become: params["product"]["cost"] But is there any way to do this using form_for? ...

delete child when parent is deleted is not working.

Well the situation is bit more complicated than that ! I have a question model class Question < ActiveRecord::Base has_many :answers, :dependent => :destroy then an answer Model class Answer < ActiveRecord::Base belongs_to :question, :counter_cache => true has_many :rep_events, :class_name => "RepEvent", :foreign_key => "event...

Can someone check what's wrong with this code?

I'm sorry for the title nad no idea what to name if, anyone mind changing it for me? Hey guys, I'm not sure if I'm able to do this or not in rails, but I tried it just to see if it'll work or not, hopefully someone understands what I'm trying to do <% @grinders.each do |grinder| %> <div id="main"> <div style="float:left; height:80p...