ruby-on-rails3

Routing in Rails 3: Map with options?

I can't seem to find documentation on mapping routes with options in rails 3. As a specific example, I need to translate map.with_options :controller => 'users' do |signup| signup.signup '/signup', :action => 'landing', :conditions => { :method => :get } signup.premium '/signup/premium', :action => 'new', ...

Using variables (database requests) in the config.ru

Hi, I'm new to Rack and try to get my head around it running Ruby on Rails 3.0.0.beta4. I'm starting a Rack app in the config.ru file but would like to use a variable there that is stored in my database. Is it even possible to get a database value back before the application is loaded or am I missing the point completely? I'm using th...

Rails 3 XSS Escaping Breaks Plugins

Is there a relatively easy solution to Rails 3 auto escaping to not break view-oriented plugins? I'm using table_builder which has an api along the lines of: <%= calendar_for(args) do |table| %> ... <% end %> Unfortunately, rails goes through and escapes all the html generated from that plugin. Is there an easy way to avoid this be...

Does rails 3 also escape field data that's sent via ajax?

I know that rails 3 automatically escapes user input, but does it also do this for user input that's submitted via ajax such as an auto-complete query? ...

Facebooker and Rails3 with OpenGraph

Hi all, The facebook rest API is apparently deprecated and is going to disapear soon. This Api is replaced by the new OpenGraph Api. Right ? I'm looking for a way to replace Facebooker with a plugin able to handle the facebook open graph and working with Rails3. I looked over the web and i didn't found something interesting about thi...

Using a resource_name in rails 3

Hello, I'm currently working on a heavy app, and I need the same kind of information in many views. Is there something existing to replace my model name? I would like to use a generic partial. For example : Created <%=h date_format(@project.created_at) %> par <%=h @project.user_create.aka rescue nil %> You could have the same thing f...

Flash Messages in Partials (Rails 3)

I have a partial, _flash.html.haml - flash.each do |type, value| .flash{ :class => type.to_s } = value Which I'm rendering from a view using =render :partial => "flash" Which complains that the flash hash is nil/undefined. However, when I do this: =render :partial => "flash", :locals => {:flash => flash} It works. Why does...

Capturing Rails 3 Multiselect Input Params

I have a multiselect form control (fig. 1). When I select more than 1 value, Firefox sends both values (fig. 2). But only the last value gets sent as a input value to my controller (fig. 3). How do I get all those values passed on to my controller? <form action="html_items/search" method="post" > <!-- Criteria --> <div styl...

Are there any tutorials or guides for setting up an Apple Push Notification server in Rails (3.0)?

I've got an app that I am building in Rails 3 (and MongoDB using Mongoid). I want to be able to send Apple Push Notifications to iOS devices. I am aware of PRX's apn_on_rails and samsoffes' apple_push_notification gems, but they do not appear to work correctly in Rails 3. Are there any tutorials out there for setting up an APN server in...

How to patch a gem to work properly in Rails 3

I am trying to use a particular gem that hasn't been updated since the inception of Rails 3. It makes a reference to RAILS_ROOT when the gem is initialized, which gives me this: can't convert #<Class:0x1018695c8> into String (TypeError) From my understanding, this is because Rails 3 doesn't set Rails.root at this stage of the initiali...

Can you recommend a good RoR 3 book?

I want to buy only one book, which one would you recommend? It has to be RoR 3.0 (its OK if the book is not published yet, RoR 3.0 itself is not released yet), I can do a pre-order. Its OK if the book doesn't deal with Ruby (in fact its better), there are quite a few good free online Ruby books online. ...

Sinatra app as Rails 3 subpath

I'm trying to get a sinatra app as a subpath in my rails 3 app. Specifically, the resque queuing system has a sinatra based web interface that I would like to have accessible through /resque on my usual rails app. You can see the project here: http://github.com/defunkt/resque I found some people talking about adding a rackup file and ...

Can't get controller test working with RSpec 2 and edge Rails 3

Not sure if this is a Rails 3 issue or an RSpec 2 issue, but I can't seem to get a standard controller test working - it seems that the 'get' method can't be found. I have a controller test that looks like this (named discrepancies_controller_spec.rb in spec/controllers directory): require 'spec_helper' describe DiscrepanciesControlle...

Foreign key (class_id) not populating in belongs_to association

Hello, I'm new to rails and building a small test app on rails3 (beta4). I am using Authlogic to manage user sessions (setup in a standard fashion as per this tutorial) I have scaffolded and setup a card model (a post basically), and set up the basic active record associations for a belongs_to and has_many relationship user.rb has_m...

Is there a way to check if a record was built by another model in active record?

hey, When using accepts_nested_attributes_for, I got stuck when having a validation which required the original to be present. The code will help clear up that sentence. class Foo < ActiveRecord::Base has_one :bar accepts_nested_attributes :bar end class Bar < ActiveRecord::Base #property name: string belongs_to :foo valida...

Using Unobtrusive JavaScript to Update an Element

As you know, when you upgrade from Rails 2 to 3 you replace this: link_to_remote "more", :url => {...} with this: link_to "more", {...}, :remote => true But how do you handle the :update option in link_to_remote? In Railscast #205 Ryan Bates demonstrates link_to with :remote and a server response that includes JavaScript code to up...

Rails 3 CRUD shallow nested model

Hello ! I'm trying to use this example but it doesn't work. I guess it's because I use a shallow nested model ! I get this error : Template is missing Missing template pprojects/create with {:formats=>[:html], :handlers=>[:builder, :erb, :haml, :rjs, :rhtml, :rxml], :locale=>[:en, :en]} It looks like my app is trying to do HTML and no ...

Rails 3: datetime_select with am/pm options

In Rails 3, is there a way to use datetime_select and display hours showing 12 hour am/pm options rather than 24-hour options? ...

How to disable the database on Rails 3 for a webservice-based application

I am making an application that does not, as of now, require a database. So I want to disable it! I am making this with Rails 3beta4 with Postgres 8.4.x. In order to serve up a view, Rails 3 seems to need the database specified in database.yml to exist--why? I never checked this with Rails 2.3, but it seems silly that it should need to...

render :action with params

hello, I have one Class with 2 methods. The first method is called by the view with some GET parameters ( params[:page] ). I would like to save those params and send them by a render action to my second method. class exemple def first ## sql save of params[:page] render :action => "second" end def second ## ## H...