ruby-on-rails

how can you tell if session cookies are being used?

If I'm looking at someone else's rails app, what's the first place to look if I want to know where their sessions are stored - cookies/db? ...

How to show public version of user profile in Rails?

I have a User model that contains information such as username, email, hometown, etc. When the user is logged in, he can edit any of his information via the show page (/users/723, for example). I'd like to have a "public" version of this page that can be viewed by someone that's not logged in or by someone that's logged in as someone e...

ERB vs HAML conversion of an if condition?

I am getting started with HAML and am working on my converting my first file. The ostensibly correct omission of the "- end": - if current_user = link_to 'Edit Profile', edit_user_path(current_user.id) = link_to 'Logout', logout_path - else = link_to 'Register', new_user_path = link_to 'Login', login_path gets me: app/views/layouts/a...

New Action Not Working

I have a standard User controller with the normal set of actions (index, show, new, edit, etc) and I'm trying to add a new action named 'profile'. I added the following code: def profile @user = User.find(session[:user_id]) end I also created a new view for the action (app/views/users/profile.html.erb), but whenever I try to view...

How do I get a Rails application to talk to a web service that wraps some C# logic ?

This is more of a technology stack question. the C# logic is pre-existing / legacy and is internally a multiple-machine/distributed app. My need is to implement an overview web interface. So I've been looking at doing a prototype in Ruby On Rails. Now my knowledge is a day or 2 old here... so correct me if i am wrong. there used to be ...

Rails ContactForm with non ActiveRecord model - validations

Can anyone share a few guides, tips or links to what constitute best practices for creating a model that represents a contact form which is not backed up by a table in the database, but can still validate the data entered? Thanks. EDIT: I forgot to mention, that if it is a gem or a plug-in, it should work with Ruby 1.9.1 on Rails 2.3.2...

What is the best Ruby pattern to use in this Rails situation?

The interaction of the site is based on the input of user. For example, if the user selected "VISA" as payment method, he will be redirected to another controller/actions asking for credit card number. If the user selected "Paypal", then he/she will be redirected to an external website. Instead of putting all logic in the action itself...

Grouped Select in Rails

Simple question really - how do I use the select(ActionView::Helpers::FormOptionsHelper) with grouped options? I have got it working with a select_tag (ActionView::Helpers::FormTagHelper) but I would really like to have it using a select tag to match the rest of the form. Is this possible? My options look like this: [ ['Group 1', [...

jRails Alternative

Hello, do you know an alternative to jrails? It's more or less outdated (uses jQuery 1.5 - now 1.7 is the current release). Does anybody know an alternative? Thanks EDIT: I know how to build the rails helper with jquery allone - but I like the rails helpers, so I dont want to use jquery allone (without jrails) ...

Gem-idea: Automatic spam protection with captcha in before_filter when HTTP-method is post,put or delete

I'm thinking about writing an automatic spam protection system (maybe I will write a public gem) for rails. My concept is to include a helper method in application_controller f.e.: class ApplicationController < ActionController::Base automatic_captcha_redirect(:min_time => 30.seconds :limit => 50) ... end Then I want to include aut...

"patch" rails render function to edit default options..

when I render :xml in rails I always want the :dasherize => false options. Is there a way to set it application wide as the default, without having to modify rails source code of course? maybe a render function that somehow takes precedence over the first one and then calls it with this option... ...

Variable cost subscription payment provider UK

Hi all, I am looking for a payment provider that uses an API and supports variable cost subscriptions that I can integrate into my Rails application. We are currently using the Active Merchant plugin for Rails and PayPal as our provider but their recurring billing procedure is apparently flaky. I'm thinking that there may be a provider ...

page.insert_html does not insert html with link_to_function (rails)

Hi there, I'm triying to do a complex form in Ruby On Rails. It should be divided in groups, and each group should have text fields. I want groups and text fields to be added and removed dinamically. I already managed to get Text Fields added and removed dinamically, but I am totally unable to do the same with the groups. This is the...

Heroku eating my custom HTTP Headers

I'm using Heroku (heroku.com) to deploy my rails application, and am building an iPhone client to interface with it. My intention was to pass the unique device identifier of the phone to the app as a HTTP header for authentication. When I test locally, my headers come through fine, but on Heroku it seems to strip out my custom header. I ...

Rails: How to get the servers response HTTP headers?

Hi, I want to autodetect the pingback-url of remote websites, so I need to parse the HTTP response headers sent by the remote server. I don't need and don't want the contents of the remote website, I'm only looking for something like this: X-Pingback: http://www.techcrunch.com/xmlrpc.php Similar to using curl: curl -I "your url" I...

Listing subclasses doesn't work in Ruby script/console?

This works: >> class Foo >> def xyz() >> Foo.subclasses >> end >> end => nil >> class Bar < Foo >> end => nil >> class Quux < Bar >> end => nil >> Foo.new.xyz() => ["Quux", "Bar"] But this doesn't. User is a class in my application. >> User.subclasses NoMethodError: protected method `subclasses' called for #<Class:0x20b5188>...

Which CouchDB adapter for Ruby should I use?

Some of the options I've found are ActiveCouch CouchREST Couch Potato RelaxDB couch_foo I prefer projects that are on GitHub, since that makes it easiest for me to fork and push fixes. All of those fit that requirement. I'm used to Rails, so I like things that act like ActiveRecord models. On the other hand, I also don't want too ...

What's the standard for percentages in Active Record?

I've been looking all over, and really just need a definitive answer to ride on. I'm going to have an object that contains percentages compiled from other objects, the point here is, what's the standard for representing a percentage in rails, without it getting broken in data migrations and things like that. ...

Rails/Prototype "submit_tag" not working in Firefox

I have the following Rails partial... <% remote_form_for :ride, :url => {:action => "create"}, :html => {:id => form_name} do |f| %> <%= f.error_messages %> <td> <%= f.text_field :name %> </td> <td> <%= f.text_field :land %> </td> <td> <%= f.text_field :height_restriction %> </td> <td colspan="2"> <%= sub...

Submitting POST data from the controller in rails to another website

In the web app I'm building with ruby on rails I have a form that the user submits with some basic data. The data is retrieved in the controller and more information that needs to remain private is added. Then I need to send a post request to an external website with all of the combined data from the controller. What is the best way to...