ruby-on-rails

How to use a yml file in my plugin?

Lets say my file lives in the config folder and it's called config/foo.yml. I want to write in that file something like this: development: status: developing foo: dev-bar production: status: on-air foo: prod-bar And then, I want my plugin to read this file and take the correct configuration values according to the environment...

Functional test "get" requests and the https protocol

I'm trying to write a functional test for an action that must run over https. I'm not testing the HTTPS redirect - I already know that works from another test. What I'm trying to do is: get :new, :protocol => "https://" assert_redirected_to :root But this does not issue the request over https. Is there a "get" option that will allow ...

Compiling / building ruby online from a working rails application

I'm totally new to Ruby but not to programming. All I did was going through try ruby and reading differences from other few languages I know better (mostly PHP and some Python). So I have no idea how Rails differ from Ruby and maybe this is an absurd question. Anyways... I don't want (or am able) to install Ruby on my machine and I'd ...

rails: how can I make a polymorphic link to a certain action

I have a class Document (in a mongodb collection) and persist various sub classes (like Page < Document). Now I do a Document.all()- how do I generate links to the document's edit action pointing to the right controller (PageController for pages) without being verbose about it? <%= link_to document.title, [:admin, document] %> points ...

Can't get PayPal Encrypted Website Payments to work in Rails

Hi all, I am having problems getting PayPal Encrypted Website payments to work on a Rails site. I am getting two different error messages when posting to the PayPal URL - on my staging site, which uses the sandbox, I am getting: The certificate has been removed. Please use a valid certificate. Whereas on the production site, I ge...

NULL in (NULL) does not match properly...

Using Rails 3 active relation, I have a scope: scope :duplicate_contact, lambda {|contact| where( :person_id => contact.person_id, :salutation => contact.salutation, :first_name => contact.first_name, :last_name => contact.last_na...

How do I use searchlogic to search on a belongs_to association?

Contact belongs_to status_contacts I only want those Contacts where no value has been assigned. I installed the searchlogic plugin. I tried: contacts = Contact.status_contact_null And got an error. How can I get a full sense of how to use associations with searchlogic, and how can I use it for this particular search? ...

Encoding in Ruby 1.8.7 or 1.9.2

I have been trying to use the gem 'character-encodings' which doesn't build in 1.9.2 however it does in 1.8.7 but even when I require 'encoding/character/utf-8' I still cant do the simplest of encoding. require 'encoding/character/utf-8' str = u"hëllö" str.length #=> 5 str.reverse.length #=> 5 str[/ël/] #=> "ël" I get ruby-1....

Rails plugin to filter abuse words / expletives ?

I've been looking, but can't seem to find a RoR plugin/gem for filtering out abuse words / expletives from strings. Do you know of a RoR plugin that does this? Ps. I do understand that there are many ways that such words can be displayed (like shit, shït, shıt, śhit, and śhiŧ). If a plugin can filter out such "words" as well, that's a...

How to prevent Rails ActiveRecord from logging blob contents?

I'm writing a Rails 2.3.8 application and appreciate the ActiveRecord default logging configuration in development mode which is to show the SQL queries and their values at the server console. But, in the case of blob values I would prefer not seeing them. Is it possible to maintain the same logging level but without getting blobs cont...

if a value from controller is nil, how do I display 0?

I am creating a report which looks for the number of emails sent during a period of time: I display it in the View as follows: <td><%= @emails_sent.size %></td> And it is generated in the Controller as follows: @sent_emails = ContactEmail.all(:conditions => ['date_sent >= ? and date_sent <= ?', @monday, @friday]) But sometimes ...

this SQL appears to be giving weird results with multiple JOINS, how do I correct it?

I have several Rails Active Record Models: ContactEmails, ContactCalls, ContactPostalcards. Each one represent a completed activity: a completed email, call, or postalcard to a specific Contact, and each Contact belongs to a Company. I want a high-level summary by Company of all the Emails, Calls, and Postalcards within a specific dat...

What's the best ruby gem for image uploads?

Hey everyone, I've been dealing with Rails 3, Paperclip and Windows 7 for a few nights now and don't feel like I'm actually getting anywhere. I've hit config issue after config issue and it's a bit of a nightmare. Can anyone recommend any other gems that will accomplish the same thing? Thanks, Brandon ...

Adding additional fields (with validation) to Devise view/model in Rails app

It seems there's not a whole lot of documentation out there covering how to add custom fields to a Devise authentication solution in a Rails 3 app. Along with the required e-mail and password for users to sign up, I'd like a few other custom fields put in and validated and since there are no controllers generated with Devise, how does ...

Evaluate whether date is not one of past dates in model -- Ruby on Rails

I have a Day model which has a date column. I have to implement the validation that the date column must not have a past date. If the date is a past date it must not get saved to the database and give the appropriate error message right on the. I know I can put this validation in the controller, but I think it violates the MVC rules i.e ...

ROR + How to make Textarea with few conditions of validation and property .

Here, In my code I have to put one of the text_area and i have to put some certain condition over them. Code which was used by me. Ruby Code:: <%= text_area "rate_unit","rate_unit_notes", "rows" => 3, "cols" => 50, :tabindex=>3, :maxlength=>100 %> HTML Code after executing the page <textarea tabindex="3" rows="3" name="rate_...

Ruby on Rails: How do you convert a database entry with attributes inside into a human-readable format?

I'm using the acts_as_auditable plugin, and the revisions attribute gives me this chunk of text (i.e. in the "revisions" column; i.e. @audit.revisions) --- user_id: 2 kind: French name: Delicious Pies I'm trying to convert that text into a human-readable format to display the details of the audit. For instance, I want to convert the ...

How to update Ruby on Rails app after deployment?

Let's say I have deployed my Rails app on a VPS, and everything works fine. MySQL is populating. Then I wanna change the functionality or view of the app. What should I do next? Probably using CentOS, Passanger, nginx, MySQL and GIT. ...

Is everything in Ruby can be used in Rails?

It might be a silly question, but seriously is everything in Ruby works in Rails? I mean is that rails did not overwrite anything, but just added new things to ruby, right? (Sorry for the silly question. I just learnt rails for about 4 months and no any experience in ruby yet (except rails ;D)). ...

Scoped match routes in Rails

Is it possible to set scope for match routings. I have tried this: scope "/admin" do match ':controller/:action/:id' emd But it doesn't work. ...