ruby-on-rails

Rails - Select a specific record from model (Checkbox) and displaying it

Hello I'm using ryan Bates railscast on HABTM checkboxes.... I looking for the way to call a specific record from the set, allow me to explain. In my view I have <% for interest in Interest.find(:all) %> <div> <%= check_box_tag "user[interest_ids][]", interest.id, @user.interests.include?(interest) %> <%= interest.name %> </di...

header and footer in Prawn PDF

Hello all, I have read through all relevant posts on Prawn but found no mentioning (even in Prawn's own documentation) of headers and footers. However, I did see a demo on Prawnto's own website about headers and footers. I copied the entire source of that demo just to see if it works but an error of undefined method "header" is complai...

Is this the correct way to set up has many with multiple associations?

I'm trying to set up a new project for a music site. I'm learning ROR and am a bit confused about how to make join models/tables. Does this look right? I have users, playlists, songs, and comments. Users can have multiple playlists. Users can have multiple comments on their profile. Playlists can have multiple songs. Playlists can have ...

Changing href attributes with nokogiri and ruby on rails

Hi, I Have a HTML document with links links, for exemple: <html> <body> <ul> <li><a href="http://someurl.com/etc/etc"&gt;teste1&lt;/a&gt;&lt;/li&gt; <li><a href="http://someurl.com/etc/etc"&gt;teste2&lt;/a&gt;&lt;/li&gt; <li><a href="http://someurl.com/etc/etc"&gt;teste3&lt;/a&gt;&lt;/li&gt; <ul> </body> </html...

Rails Authlogic authentication method

Within Authlogic, is there a way that I can add conditions to the authentication method? I know by using the find_by_login_method I can specify another method to use, but when I use this I need to pass another parameter since the find_by_login_method method only passes the parameter that is deemed the 'login_field'. What I need to do i...

Best way to handle multiple tables to replace one big table in Rails? (e.g. 'todo_items1', 'todo_items2', etc., instead of just 'todo_items')?

Update: Originally, this post was using Books as the example entity, with Books1, Books2, etc. being the separated table. I think this was a bit confusing, so I've changed the example entity to be "private todo_items created by a particular user." This kind of makes Horace and Ryan's original comments seem a bit ...

Rails - building an absolute url in a model's virtual attribute without url helper

I have a model that has paperclip attachments. The model might be used in multiple rails apps I need to return a full (non-relative) url to the attachment as part of a JSON API being consumed elsewhere. I'd like to abstract the paperclip aspect and have a simple virtual attribute like this: def thumbnail_url self.photo.url(:thu...

Rails Application Hosting

Where do you host your rails applications? I've tried Heroku and Slicehost. I thought I would ask you, the knowledgeable guys here at stack-overflow, for hosting recommendations. Thanks in advance -- Deb ...

Add querystring parameters to link_to

I'm having difficultly adding querystring parameters to link_to UrlHelper. I have an Index view, for example, that has UI elements for sorting, filtering, and pagination (via will_paginate). The will_paginate plugin manages the intra-page persistence of querystring parameters correctly. Is there an automatic mechanism to add the query...

catching the value of a time_select in rails.

Hello, I have a form that has two field (time_selects), the idea is that the user can select the beginning of a call and end time of the call. I've setup a observe field and works fine: <%= observe_field "llamada_inicio_4i", :update => "total", :with => "llamada_inicio_4i", :url => { :controller => "llamadas", :action => "time_tr...

Searching in Ruby on Rails - How do I search on each word entered and not the exact string?

I have built a blog application w/ ruby on rails and I am trying to implement a search feature. The blog application allows for users to tag posts. The tags are created in their own table and belong_to :post. When a tag is created, so is a record in the tag table where the name of the tag is tag_name and associated by post_id. Tags are s...

Problem accessing variable in a nested form partial

I have a nested form in a rails view that is called like this <% f.fields_for :invoice_item_numbers do |item_no_form| %> <%= render 'invoice_item_number', :f => item_no_form %> <% end %> and the partial (_invoice_item_number.html.erb) looks like this <div class='invoice_item_numbers'> <% if f.object.new_record? %> <li><%=...

rails & markdown error: uncaught exception: Control.TextArea requires Object.Event to be loaded.

So, I've got bluecloth installed and I'm trying to use the Control.TextArea javascript WYSIWYG editor. Anyways, I followed the tutorial on the page and when I load the corresponding view, I get an error: uncaught exception: Control.TextArea requires Object.Event to be loaded. This comes from Control.TextArea js file. Any ideas? Tha...

How to do recurring with bank account payment mode using authorized.net

Hi All, I am using recurring facility of authorized.net using active_merchant plugin in rails. there are two payment method for this 1] Credit Card 2] Bank Account I successfully done it using Credit Card For Recurring i need my Test Mode off. Also my E-check, credit card processing, and subscriptions are all enabled. But i am not...

Routing in PHP vs routing in Rails..

I was working on PHP in the past 1 year and nowadays I'm learning Rails. In rails:-- Routing takes an incoming URL and decodes it into a set of parameters that are used by Rails to dispatch to the appropriate controller and action For example rs.recognize_path "/blog/show/123" {:controller=>"blog", :action=>"show", :id=>"123"} Am ...

Is there a way to undo Mocha stubbing of any_instance?

Within my controller specs I am stubbing out valid? for some routing tests, (based on Ryan Bates nifty_scaffold) as follows :- it "create action should render new template when model is invalid" do Company.any_instance.stubs(:valid?).returns(false) post :create response.should render_template(:new) end This is fine when I test t...

1 has_many:.., :through and 1 has_and_belongs_to_many: .. problem??

The following are the models and association. class Vendor < ActiveRecord::Base attr_accessible :name, :address_attributes has_many :campaigns has_many :clients, :through => :campaigns end class Client < ActiveRecord::Base attr_accessible :name has_many :campaigns has_many :vendors, :through => :campaigns end class Campaig...

Getting Paperclip to work in Rails

Hi Everyone, I have installed the Paperclip plugin to attempt to upload an avatar for my kase model. For some reason, the select the file button shows, and I can choose a file - but then when I click update the kase - it takes me to the show page, but the missing.png rather than the selected image. kase.rb class Kase < ActiveRecord::...

when does factory girl create objects in db?

i am trying to simulate a session using factory girl/shoulda (it worked with fixtures but i am having problems with using factories). i have following factories (user login and email both have 'unique' validations): Factory.define :user do |u| u.login 'quentin' u.email '[email protected]' end Factory.define :session_user, :class =...

convert jruby 1.8 string to windows encoding?

Hey, I want to export some data from my jruby on rails webapp to excel, so I create a csv string and send it as a download to the client using send_data(text, :filename => "file.csv", :type => "text/csv; charset=CP1252", :encoding => "CP1252") The file seems to be in UTF-8 which Excel cannot read correctly. I googled the problem and f...