ruby-on-rails

Different DB connection for individual model depending on environment

Hi there, I have a Model (MessageImporter) that connects to a different Database than the other models using self.establish_connection. Everything works fine when I pass the connection info hardcoded. Now I need the connection to depend on the current environment. So I added the info to my application_config.yml (it's a simple nifty_con...

Friendship invite form with hobo

Hello, The hobo lifecycle tutorial shows how to implement a friendship logic in the model and controller. However it does not really cover how to glue the gui/views together. When I go to /friendships/invite - hobo presents me with a form with a drop down menu. How do I add a form to the user show-page with just one button (Invite) I gu...

don't understand few lines ruby codes

Hi, I'm working on a ruby on rails project which is developed by someone else rails expert. I don't know ruby well. So while i modifying the existing project, i could not fix a bug because i didnt understand few lines code. It will be great if someone explain. Here are the codes - on my home controller - home_controller.rb class Home...

Setting up local web server on Mac for Ruby on Rails

I use MAMP for PHP/MySQL. What do I need for RoR? I am using OS X Leopard. I have already installed Ruby, Gems and Rails. ...

Rails unit tests: How to add my own output to unit test results

Hi, When running Rails unit tests I get output specifying line numbers and methods when a test fails, e.g.: 1) Failure: test_05_photo_tag_add_remove(TC_javascript02Test) [./helper/helper.rb:6:in `handle_assert' ./helper/helper.rb:17:in `check_not_string' ./helper/helper.rb:134:in `check_for_ajax_remove_string' javas...

RoR: how to use other obj outside my own folder?

I found that I only can @products in the views/products/ folder, I can't call the @products in other position, like views/store ..... .... If I want to use the @products in the view/store, wt should I do? apart from calling /views/products. ...

Rails, Thinking_sphinx, Delta Index

Hi, I'm using thinking_sphinx and am delta indexing a model. The delta index works but there is small bug. When I create a new product it is index. However, when I update that product it is not getting index right away. I have to update or create a new product before that old updated product is indexed. Not quite sure where to start. ...

Ruby on Rails: Aggregating several columns into an Array

I'm developing a Ruby on Rails app where one of my database tables has 10 columns (pile_1 through to pile_10). It would be convenient to access these columns in the model as a 10-element Array. It feels like I should be able to coerce composed_of into doing what I want, but I can't figure out how. Can anyone enlighten me, or suggest a b...

RoR: not able to connect paperclip to Amazon S3

Hi, I have decided to deploy my app to Heroku and I was following their tutorials. However, Im trying to connect to my Amazon S3 bucket with a paperclip plugin right now and Im getting this error: ArgumentError in Images#index Showing app/views/images/index.html.erb where line #19 raised: syntax error on line 0, col 39...

<%= debug(controller) %> produces unreadable output

In one of my templates I want to take a closer look at the controller object using the debug() helper. It is said to produce YAML suitable for HTML output. Running <%= debug(controller) %> does, however, not produce anything I call readable. It begins with: #<ClubsController:0x104467378 @_request=#<ActionController::Request:0x1044676...

text field with dropdown in rails

Hi All, I'm trying to build a form field that can either accept a text entry, or select an option from a dropdown. In rails, the autocomplete plugin is close to what I need, except I want the dropdown to be available before the user types anything in the text field. Is there an example of this out there somewhere? thx for the help, -...

What can I expect as the core stack for Rails 3.0 and what will I need to include now as a plugin

So Rails and Merb are sort of merging in Rails 3.0? Thats how its been described to me anyway. This means that a lot of what made Rails, Rails will now be moved to plug-ins so that it can be more lightweight. HOwever, what are those plug-ins going to be and as a new Rails developer, what are THE must have - and also more mature - plug-in...

Rails: Referring back to model the object belongs to

This is probably a dumb question, but I can't seem to find a good answer. I want to know the best way to refer back to the model that an object belongs to. For example: class User < ActiveRecord::Base has_many :posts end class Post < ActiveRecord::Base belongs_to :users end So, to get the user's posts, I can use user.posts, b...

Ruby on rails - nested attributes: How to do a find or create of the nested model

I have a Bill model with nested Customer model. The Customer model has a phone number with a uniqueness validation on it. While creating the bill I want to fetch the existing record based on the phone number or create a new one if such doesn't exist. How should I do it in a RESTful way? ...

What technologies does Rightmove.co.uk use? PHP? Ruby? Python? Mysql?

Does anyone know how rightmove.co.uk is made? What technologies, databases, programming languages are they using? PHP? Ruby? Python? I can see that it is using Apache. I would really love to know what database they use. Thank you in advance ;-) ...

Unable to install MySQL on Mac OS X

Hey, I'm having the exact issue as described in this question: http://stackoverflow.com/questions/354194/mysql-installation-troubles. Unfortunately none of the answers helped me (and it's closed). I try to learn Ruby on Rails and don't get MySQL working (so it is programming related). I typed: rake db:create and got: !!!The bundled m...

Passing an array into hidden_field ROR

I'm trying to pass an array into a hidden_field. The following User has 3 roles [2,4,5] >> u = User.find_by_login("lesa") => #<User id: 5, login: "lesa", email: "[email protected]", crypted_password: "0f2776e68f1054a2678ad69a3b28e35ad9f42078", salt: "f02ef9e00d16f1b9f82dfcc488fdf96bf5aab4a8", created_at: "2009-12-29 15:15:51", upd...

Using factory_girl in Rails with associations that have unique constraints. Getting duplicate errors.

I'm working with a Rails 2.2 project working to update it. I'm replacing existing fixtures with factories (using factory_girl) and have had some issues. The problem is with models that represent tables with lookup data. When I create a Cart with two products that have the same product type, each created product is re-creating the same pr...

uninitialized constant Active Scaffold rails 2.3.5

Hi guy, I update my rails application 2.0.2 to 2.3.5. I use active scaffold for the administration part. I change nothing in my code but a problem is coming with the update. I have a controller 'admin/user_controller' to manage users. Here is the code of the controller: class Admin::UserController < ApplicationController layou...

Deploying rails application

Hi, I've been playing around with rails lately and wanted to go through the deploent process just to see how it worked. I created a simple app with a sIngle model from a scaffold. I uploaded it to my server and found I needed to add /public to the URL to get the 'welcome to rails' screen. However, if I attempted to access my model (pu...