ruby-on-rails

Not rendered recaptcha in rails 3

Use of rails 3 recaptcha. In view _form.html.erb insert <%= recaptcha_tags %> But when viewing the page in the browser receives &lt;script type=&quot;text/javascript&quot; src=&quot;http://api.recaptcha.net/challenge?k=**&amp;amp;error=expression&amp;quot;&amp;gt;&amp;lt;/script&amp;gt; As I understand it is not rendered in the browse...

How do I use multiple "one-to-many" nested attributes in form_for

given the fact that a user has many credit cards and a credit card has many addresses, I am trying to create a form that creates a user and credit card with address all at once relavent model code: class User < ActiveRecord::Base has_many :credit_cards accepts_nested_attributes_for :credit_cards end class CreditCard < ActiveRecord...

What would be a better way to code this if then else clause?

I have the following code. I'm still a newbie in Ruby on Rails. As you can see I'm repeating myself 4 times. I tried something like this: if @property.nil? || @property.status_id == 144 || (@property.status_id <= 16 && current_user.nil?) || (@property.status_id <= 16 && current_user.id != @property.user_id) But it gives me lots of e...

How can I run a Rails 1.2.5 application on ruby 1.9 ?

Hi folks, I have a old app made on rails 1.2.5, this application have alot of access per day. I intend to upgrade my server (a joyent accelerator) to run ruby 1.9.x and work with rails 3 but I can't stop or move this app to another server. Have any way to run this application on ruby 1.9? or run two ruby versions (1.8.7 and 1.9) at th...

Ruby on Rails: how do I format money for my view?

This is what I have so far. how do I ensure that i'll have two decimals? and that it rounds correctly? $<%=h sale_item.value %> ...

Using Formtastic's semantic_fields_for with a has_many association

I am trying to create a nested form using formtastic. I've included my code below but am running into some problems that I've also listed below. Any suggestions? Thanks. # Home model class Home < ActiveRecord::Base has_many :home_members accepts_nested_attributes_for :home_members, :reject_if => :all_blank, :update_only => true, ...

Consuming Ruby on Rails SOAP services in Silverlight 4

Hello, I don't know how it is possible but services provided by Rails are different consumed in WPF and Silverlight. When I seek for ****.com/api/wsdl/ (it is Rails SOAP service) WPF generates all the methods, events etc. When I seek for the same URI in Silverlight I have only: [System.CodeDom.Compiler.GeneratedCodeAttribute("System....

Generate JSON in Rails for JavaScript object parameter

I'm trying to generate a chart in my Rails 3 project using the canvasXpress HTML5 / JavaScript library. Their charting API uses JSON as one of the parameters in their constructor. For example: new CanvasXpress('canvas', /* JSON here */); In Rails I'll have a view which renders the chart as part of it's overall output. So, the JavaSc...

stackoverflow style notification bar

Possible Duplicate: Notification alert similar to how stackoverflow functions The notification bar the top, which shows things like ' you earned xyz badge". How is it done? I am trying to create someting similar in my rails app. I use blueprint for my layout, it's a standard single column 950px layout, with everything from t...

trouble using compass with rails

I am trying to use compass for the first time in my rails app. compass v. 0.10.5, haml v. 3.0.10 Although I say @import "compass" at the top of my sass file, compass does not seem to get loaded. As a test, I can't use 'border-radius' on a div. The installation seems to be correct and the files in the suggested places. Any ideas on w...

How do I update a sequential attribute with foobar#{n} with n incrementing ?

I want to write basically User.find(:all).each {|u| u.update_attribute("email","nil#{incrementing_number}")} How do I make that #{incrementing_number} incremement per updated attribute. :D ...

Porting Rails 2 application to new server

I've posted a couple other questions during this process, but I have a better idea of what I'm trying to do so I thought I'd ask about that. I've inherited a Rails 2.2.2 application, which is currently running in production form on a server I have access to. I'm trying to port that application over to my server, version control, etc. I ...

What's the best way to define a scope inside of a module in Rails 3?

I have a number of models that need the same scope. They each have an expiration_date date field that I want to write a scope against. To keep things DRY, I'd like to put the scope in a module (in /lib) that I'll extend each model with. However, when I call scope within the module, the method is undefined. To work around this, I use c...

Link to call a method in a controller?

Hello folks, I made a tweet scaffold(controllers, models,views,..) in my Rails 3 app and among all the usual controller methods I have a 'tweet' method in my TweetsController. In my views, among the 'edit' and 'delete' links, I want a 'tweet' link, so this link should post the message to Twitter. Because when I simply create a tweet, it ...

Rails error: uninitialized constant ApplicationController::Authentication

Working my way through clarkware's iphone-rails-tutorial and trying to build and run the final rails code that is included but I get this error in the server's console whenever I try to access localhost:3000/ ActionController::RoutingError (uninitialized constant ApplicationController::Authentication): app/controllers/application_cont...

Can node.js replace Ruby?

Hi, I'd like to know if it's possible to create a complete website using node.js (just like we do using Sinatra and Rails). Also, is there any framework as good as Sinatra and Rails? Is this the best use for node? Regards. ...

Rails fixtures encoding error "incompatible character encodings: ASCII-8BIT and UTF-8"

Using ruby 1.9.2 and Rails 3 I get an encoding error when I try to run this in seeds.rb: Fixtures.create_fixtures("#{Rails.root}/db/seed", "countries") I am sure the .csv file is encoded in UTF-8 and it can be read and parsed using ruby's CSV class. Is this a Rails 3 encoding issue with fixtures? ...

Ruby On Rails - Where would I look for the source function for render :partial => 'x' in a view?

I am modifying a Ruby Rails application - Redmine. I want to modify a function that renders a partial preview. In the view I believe this is accomplished via <%= render :partial => 'documents/form' %> I need to modify the function this is attached to. Where might I look for this? Is render the function I am looking for? Is :parti...

Rails DB: How to cache complex calculations? Memoizing? Separate table? Action caching?

For my site, I have models Category and Product, with hundreds of categories, each having thousands of products. For the Category views, I'd like to do something like average price of all the products included. And for the product views, I'd like the average for that product's category to appear. So, with thousands of these calculations...

When to use node.js vs sinatra vs rails?

Hi, What are the best uses for these 3 languages/frameworks? Is it useful to mix all of them (or 2)? ...