ruby-on-rails

Rails "Badge" type plugin / tutorial?

Does anyone know if there is a Rails gem/plugin/tutorial that shows how to create a Badge/Achievement system similar to what stackoverflow uses. Thanks. ...

Create a webservice that keeps data secure?

I want to create a webservice that allows users to enter the longitude and latitude for a particular building. Buildings will belong to a broader category called a Region. If a specific building does not exist in a region the user could add the longitude and latitude data through the webservice. Similarly if a user finds data to be in...

How do you create RoR Factory associations with accepts_nested_attributes_for?

As Anton points out (thanks Anton!) my problem is Association Caching in the tests and it seems like I did correctly create the nested_attribute in the Factory. The correct syntax is: Factory.define :job do |f| ... f.vehicles_attributes [{:vin => "1", :model => "ford", :make => "escort"},{:vin => "1", :model => "ford", :make => "es...

Why does activeresource.rb just call active_resource.rb?

Here are the entire contents of activeresource.rb: require 'active_resource' Could someone explain the logic of this? Why not simply have activeresource.rb contain what active_resource.rb contains and forget about the additional require statement? ...

Rails: Error using ActionView method sanitize in Lib

I am attempting to use the Sanitize method from ActionView. The line r_str = Helper.instance.sanitize(r_str, :tags => @@allowed_tags, :attributes => @@allowed_attribs) is giving me the error undefined method `white_list_sanitizer' for Parsers::HTML::Helper:Class This is my code in lib/parsers.rb module Parsers module HTML @@al...

What is the difference between FormHelper::label and FormTagHelper::label_tag?

I'm writing a form which is dealing with multiple models. Some examples of how to do this use ActionView::Helpers::FormHelper::label, and some use ActionView::Helpers::FormTagHelper::label_tag, and I don't really understand the difference. In my particular case, both seem to result in the same output: <% form_for :post, :url => { :act...

Why isn't my logo appearing on my partial page in Rails?

I have made a application and the logo appears on every page. All 3 of my layouts are copy and pasted to be identical. I have 2 partials linking to 2 pages in the same view folder and the logo works with one and doesn't with the other. It just displays the "alt" name of the <img>. Is there a way to fix this? ...

Detecting regional settings (List Separator) from web

After having the unpleasant surprise that Comma Seperated Value (CSV) files are not necessarily comma-separated, I'm trying to find out if there is any way to detect what the regional settings list separator value is on the client machine from http request. Scenario is as follows: A user can download some data in CSV format from web sit...

How to verify that the assoication is valid

I have a model called Profile which is belong_to User, so there is 'user_id' for the database to keep track of. In the local admin interface I made for this model I wanted to provide the flexibility of allowing admin to enter an username to a field in the editing screen, and then resolve that to user_id for saving in controller. However...

Single RSS feed for multiple resources

My rails app has couple of content generating resources like Article, Blog Posts, etc.. I can generate the RSS for each individual resource but I'm not getting how to synchronize into one RSS feed for these multiple feeds. Currently I've setup the Articles feed via FeedBurner and even FeedBurner doesn't have this facility to merge diff...

Why does facebook.feed.publishUserAction strip my image out?

I'm using the Facebooker plugin in Rails to publish a user action to their newsfeed, but the image isn't being added. The call (via Net::HTTP.post_form) looks like this: Posting to http://api.facebook.com/restserver.php with {:api_key=>"4f5ed28f76142adsfasdf029c98ad", :template_bundle_id=>"107345673712", :template_data=>"{\"project\"...

Why are autoload, load_all! and require all used in active_support.rb?

I was looking at active_support.rb to try to understand the load process it uses. It uses three loading methods: load_all!, autoload and require. Why use three different ways of loading in the same file? module ActiveSupport def self.load_all! [Dependencies, Deprecation, Gzip, MessageVerifier, Multibyte, SecureRandom, TimeWithZon...

One controller rendering using another controller's views

I have QuestionController I now have AnotherQuestionController with actions which should render using templates and partials in app/views/question/ Is this possible? Seems like it should be. I've tried render :template => "question/answer" but answer.html.erb includes partials and I get errors like "Missing template another_questi...

Developing in Ruby on Windows

I'm starting a new job soon where I'm going to be developing in Ruby and Rails on a Windows machine. I haven't used Windows for years, and the likes of Textmate, Git and Bash, are an integral part of the workflow using a Mac. So, does anybody have any suggestions or recommendations as to the best tools or work strategies to use? Or pitf...

How can you track the full sequence & order of 'require's in a Ruby app as a tree?

How can you display the hierarchy of 'require's that take place in a Ruby app? Some files require files which require additional files. However, by running an application in debug mode you only trigger a subset of required files - only the ones that are used by whatever subset of functionality your application is using at any given poi...

Identifying the caller of a method in ApplicationController (RoR)

I have a method in my ApplicationController that is part of a before_filter. How do I identify which controller is calling that method and can I pass arguments to it? Presumably worst case, I can create a new object where I use controller names and values, then call it directly in the before_filter method with NewObject.find(:first, :c...

Ruby on Rails - Variable inside a Varible

Alright. So I have a table called contacts. In this table I have people and there contact information and how their preferred method of contact (Phone, Address, Email, or Fax). I want to be able to have ruby output a list of said people in a manner I could copy paste into a email address bar or such. <% @contacts.each do |contact| %> ...

Why is it supposedly "hard" to deploy Ruby on Rails to production?

I admit that I don't follow much of anything "right" on deploying test versus production code. I have been using ASP.NET, and I typically run it locally in Visual Studio, it works, I upload it, I test it again on the production server. I have read several people say that deploying Rails apps is harder and there are special programs/way...

Recommendations for a snappy Ubuntu + Rails server

Hello, I run an Ubuntu 8.04 shared host (VMWare) with Apache + Passenger (= Mod Rails), MySQL and Acts_As_Ferret (in server mode). It's too slow at the first requests. I do a lot of REST operations on it and have very few users. Now I want to do a fresh installation... Which setup (based on Ubuntu) do you recommend for a really snappy...

What's the best way to A/B test Email Subject Lines in Rails?

I'm sending out a lot of emails in my latest rails app. I want to A/B test subject lines in the emails that go out. ideally i can capture two things. 1- open rate 2- whether the call to action in the email is clicked any ideas on how to do this? i don't think (the great) 7 minute abs (http://github.com/paulmars/seven_minute_abs/tree...