ruby-on-rails

Stress/load testing Ruby on Rails apps with Authenticity Tokens

My Ruby on Rails application is mostly contained behind a login page. I'd still like to be able to stress test these pages, as they have some heavy database access. Sending the username and password into a post for my login isn't difficult, but the Authenticity Token keeps changing, which makes my tests unrepeatable. Is there a way to...

Article stats widget in rails

Hi all, I've been trying to design a widget for my rails app and unfortunately find myself lacking in Javascript skills... I was able to create a widget based on the short guide from this blog: http://www.eduvoyage.com/2008/8/3/widget-with-rails But what I need is a little different from what they describe. If you had a digg or tweet...

Active Record: Get two random objects?

What's the simplest way to get an array with three objects (Card), one of which I already have? The other two should be randomly selected from the database. My current approach looks like this: [ @deck.cards[rand(@deck.cards.size)], @deck.cards[rand(@deck.cards.size)], @mycard ].sort_by {rand} The problem I have right now is t...

Invoking ONC RPC from Ruby?

I have a Ruby (Rails) app that needs to make some calls to a service exposed via ONC RPC. Is there a way I can readily accomplish this in Ruby or do I need to create a proxy service using another language? FWIW, my target platform is CentOS. Thanks! ...

What is the best way to exchange strings of text between Flex and Rails?

I want a Flex UI to send a string of text to Rails which will process and return a string of text. Wash, rinse, repeat. That's all I want. All of the examples I am finding are much more complex and not very informative given my noobiness. Thanks in advance, NJ ...

Why is link_to not taking me where I want it to?

Hi, I have a model 'Asset' and, on the show page, I have this: <%= link_to_remote 'test', :url => { :controller 'looks', :action => 'whatever' } %> The 'looks' controller and 'whatever' action both exist. Now when I go the the show page for the second Asset and click the test link I get this error: Processing AssetsController#2 (...

How do I send data to a Rails controller from Flex?

I am trying to use an HTTPService to send a string of text to a controller action. How do I access it within the controller? Thanks. ...

Relation Between 2 Controllers

Hello, How can I define a relationship between two controllers. I have one controller called rides and another called registrant. Is there anyway I can access the registrant database from within the rides controller? I was thinking @registrant = Registrant.find(:first) from within rides, but that didn't work. Any suggestions? Thanks ...

Deleting Mulitple Records in Rails

I'm working on an application that allows user to select multiple entries. Once those entries are selected, the user can choose to delete them all. When clicking on the delete button (after selected one or more entries), a modal dialog window is displayed showing the entries that the user has selected with a confirmation button. Current...

How should I test request-related logic in Rails development?

I have several before_filters defined in my application controller to handle requests I don't like. One representative example is: before_filter :reject_www private def reject_www if request.subdomains.include? 'www' redirect_to 'http://example.com' + request.path, :status => 301 false end end (Returning false skips any ...

Rails and beyond

I feel like I'm an intermediate-advanced Rails programmer. I've written some small client apps. However, I feel like I'm missing something. I don't really understand HTTP; what a web server is; how networking works; what Mongrel is beyond just "script/server". Are there any good books to explain what HTTP is and other stuff I'm missing o...

How do I authenticate a Flex session with Rails?

I have a Flex UI that will need to connect to Rails. How do I manage authentication and only authenticated user's can connect and see their own data only? UPDATE: And how would I do this if I should not want to use RubyAMF (right or wrong)? ...

"Auto-refill" using Paypal

So recurring monthly payments are pretty simple. What about auto-refill, like Skype (every time your account runs low on credit, you get auto-charged)? Is this possible using Paypal (in a somewhat seamless way)? I'm guessing it's a terrible idea to even think about storing credit card information. What about another payments solution...

submit data from one rails application to another

Hi, I have two rails applications. I would like to submit data from one application to another but I want it go through the controller logic as it's not just a DB dumb. I tried using directory HTTP call with POST but it didn't work as it asked for Authenticity Token. Now that I own both apps what is the easiest way in your opinion to d...

Using Rails googlecharts gem on HTTPS/SSL site

I am using the googlecharts gem in my rails app for some simple charting. It works beautifully, except my app is required to be SSL encrypted at all times. In order to pull the google charts, the charts gem of course makes an http request to google which leads to a browser warning about some insecure content on the page for most users. H...

how to display an exsiting xml file to user in RoR

Hi, I have an xml file and I want to display(render) it as it is to the user, i.e I want to keep the tags. How should I do in RoR? I have tried render :file=>"/path/to/file.xml", but the tag <product> disappeared. //file.xml <product>car</product> Update: I found the behavior is browers-dependent Mozilla/5.0 (X11; U; Linux i686; e...

SQL query builder in rails

We are trying to build a SQL query builder that would allow users to make queries using visual aid . We have got the front end all worked up with the user being able to select tables add condition etc . However our backend is a mess as we are trying to make these queries as string taking the conditions from the user , and then making app...

How can I change the method used in Formtastic?

Hi guys, I was wondering how can I specify the method to send the data from a Formtastic form. It usually uses POST, but I'd like it to use GET in some cases (i.e. for a search form). Is it possible/easy? ...

are they any commercial ecom & cms packages for RoR?

are they any commercial ecommerce and CMS type packages for RoR? ...

how do I create a simple cache of static Models in rails?

I have a few models that contain static data, and I'm trying to cache them. I've read the various guides and railscasts on caching and thought it would be simple, but still can't figure it out. For example, I have the following model class ActionType < ActiveRecord::Base def self.find(id) Rails.cache.fetch(cache_key) { ActionType...