ruby-on-rails

Save the id of autocomplete field instead of the text (Jquery autocomplete) in Rails3

Hello. I have managed to setup autocomplete field for my rails app. What I'm trying to do is to have the contents of a lookup table listed and when I have selected the lookup text for few lines I would like the id of the lookup to be saved instead of the text itself. Here is what I have done: Recipe model: class Recipe < ActiveRecor...

How the customize or change the route paths in rails?

For example consider the following output from rake routes:- posts GET /posts(.:format) {:action=>"index", :controller=>"posts"} posts POST /posts(.:format) {:action=>"create", :controller=>"posts"} *new_post* GET /posts/new(.:format) ...

Rails3 - FIND(:all) with a Join, how to include a record from the JOIN?

Hello, in my users model, I have the following: @users = find(:all, :joins => :instance, :conditions => ['fname LIKE ? or lname LIKE ?', "%#{search}%", "%#{search}%"]) The issue here is that @users only returns data from the user's table, and not the joined instance table. I confirmed this with the SQL query in the logs. SELECT "use...

Developing a Rails app in Netbeans/JRuby but deploying to Ruby (C)

I'm using Netbeans and JRuby to develop a Rails web application. But for deployment, I will be using Heroku. Since Heroku uses the Ruby-C implementation, I was wondering my use of JRuby can cause problems? Is this approach a safe thing to do? ...

Best way to make Rails view output (text) dynamic based on user properties? (similar to i18n/locales)

I need to make certain output from views dynamic based on the "type" of user logged in. Specifically, the user "type" is based on the type of business they are in and using my application, so if they are a retail store my application needs to refer to "customers", "products", "purchases", etc. whereas another type of user in a services-b...

Rails, Outputing a List of Users & Specifying if they are permissioned or not

Here's what I have today: I output a list of @users What I need to do is output a list of users and say if they are assigned to the current project. I could loop through each user and check in the database, but that would be a lot of data base hits, an additional 10 hits for displaying 10 users. My question to you, is there a smart, m...

Mongoid / Mongodb and querying embedded documents

Hi, I have an Author model and a Book model. When the Author has many embedded Books, is it possible to query for all Books in mongoid (rails 3.0.1) or do I always have to fetch the Author to get the Books? Best regards, sewid ...

running script/plugin discover doesn't return anything, what's wrong?

running script/plugin discover doesn't return anything, what's wrong? shoudn't it list all the urls from the wiki page? ...

Trying to make comments of comments. How to arrange models?

My :post model is the parent model. Within a post are many comments. And comments have potential of having many more comments, and so forth. I thought I had had this right, but I were to type : Comment.last.comments I get : NoMethodError: undefined method `comments' for #<Comment:0x1053a1ff0> My Models : #comment.rb belongs_to ...

Rails - how to count lines of code?

I tried rake stats but that seems highly inaccurate. Perhaps it ignores several directories? ...

Error when generating scaffold

I use RVM with ruby 1.9.2 and Rails. When I try to generate a scaffold for my Rails app, I get this error: <internal:lib/rubygems/custom_require>:29:in `require': no such file to load -- script/../config/boot (LoadError) from <internal:lib/rubygems/custom_require>:29:in `require' from script/generate:2:in `<main>' Is there something w...

Ruby on Rails remote_form_tag

Hi, I am trying to create a contact form using the remote_form_tag, but I cannot get it to work. <% remote_form_tag :url => {:action => :email_create} do %> <%= label_tag 'name', 'Name: ' %><%= text_field_tag :name %> <%= label_tag 'email', 'Email: ' %><%= text_field_tag :email %> <%= label_tag 'message', 'Message: '...

Redefining :all

I have users in my system that can elect to 'hibernate', at which point they can remove themselves and all of their associated records entirely from the system. I have queries all over my site that search within the User table and its associated tables (separated by as many as 5 intermediate tables), and none explicitly test whether the ...

RSpec nested-model in view spec

I am trying to write a view spec to drive out a form with a nested model. In my example every Organization has many Users. When you create a new organization you create the first user at the same time. This part works: require 'spec_helper' describe 'organization/new.html.erb' do let(:organization) do mock_model("Organization")....

RoR: Sinatra producing error "uninitialized constant"

I'm new to Ruby on Rails (formerly and currently PHP expert) so forgive my ignorance but I'm trying to get Sinatra working as middleware to redirect some old urls since I tried the gem rack-rewrite and couldn't get that to work either. I am using code samples from ASCIIcast so in my routes.rb I have the following: root :to => HomeApp ...

How to get Ruby on Rails to generate a model using sql server 2008

Ruby version: 3.0.2 Rails: 1.9.2 OS: windows 7 DB: sql server 2008 (r2) I tried to execute the following command: rails generate model product The error I get can be seen here: pastebin.ca/1965168 I tried to follow these two sites: rubyrailsandwindows.blogspot.com/2008/03/rails-2-and-sql-server-2008-on-windows_24.html www.lostechies....

Indices and capped collections with MongoMapper

What is the best way to set up an index or configure a capped collections in a Rails project? From what I've found, it seems that a good way would be to keep this configuration in an initializer. The command for setting up an index is ModelName.ensure_index :key, but what is the command for a capped collection? ...

How can i unit test a "Delete link" with Ror, cucumber - webrat ?

Hello, I am currently developing a Rails application, I'm trying to units test it. I chose Cucumber + WebRater. I'd like to test in my backend all delete link. I tried to go to visit a second argument (the method: delete) without success. (something like : visit my_path, method => :delete) On my pages I delete some links so the soluti...

The program 'rails' is currently not installed?

I've installed Ruby (1.8.7 via apt-get) and I installed Rails (2.3.2 via rubygems) but when I type 'rails newapp', I get this error: The program 'rails' is currently not installed. You can install it by typing: sudo apt-get install rails rails: command not found When I run 'gem list' it shows rails and all of it's dependencies. Any id...

rails observe_fields for dynamic menus

Hi, I am trying to make a simple nested dynamic menus, where subcategories will be shown based on what I choosed in category. But to make it very simple, I just wanted to render the same thing in the subcategory, whether I choosed "Home" or "Job" (mainly a text of "show the same" will be rendered) In index.rhtml I have this <html> <he...