ruby-on-rails

git: how to get changes nicely back into master when working with submodules

Hi there, i use the git workflow as described in this blogpost. In short: everybody develops inside his/her own branch, before merging back to master, you rebase your branch to master again to get clean history. This works. Now we have a submodule, and because this is an in-house plugin (Rails), we need to change this often. So most o...

How do I get 'rake test:acceptance' to run successfully on Windows?

I am currently investigating using the selenium-on-rails plug-in for testing an upcoming web app that we are developing. I've written some tests, and can get them to run successfully in the test runner in the browser, however when I try to run them from the command line using 'rake test:acceptance' I see the following error: rake aborte...

To continually pull result from the server via Ajax until timeout or getting result.

Hi guys, I would like to make an Ajax request to the server, which replies a job status and result. If the status is "Error" or "Ok", the client should show the result (containing HTML code) to the user. However, if the status is "Waiting", the client should wait for a few seconds and then automatically send the same Ajax request again....

why isn't my rails install using the latest version of passenger?

I'm using VirtualBox on Windows to run an Ubuntu OS, which is running the turnkey rails package, which comes with ruby 1.8, rails 2.3.8, and passenger 2.2.5. When I first booted it up with just a vanilla rails app it worked fine, but now I'm getting the following error: uninitialized constant PhusionPassenger::Utils::PseudoIO::StringIO ...

Rails File I/O: What works in Ruby doesn't work in Rails?

So, I wrote a simple Ruby class, and put it in my rails /lib directory. This class has the following method: def Image.make_specific_image(paths, newfilename) puts "making specific image" @new_image = File.open(newfilename, "w") puts @new_image.inspect @@blank.each(">") do |line| puts line + "~~~~~" @new_image.puts line if...

How to convert an ImageScience image to something S3/AWS can upload

Hi all, I initially store a jpeg in a variable (it is the balue I reveive from an HTTP get over net/http. Ig I input this directly into AWS, it works fine. However, I would like to resize it and then stuff it into AWS and I always get a warning "size not a method' on IMAGESCIENCE object. I tried onverting it to to_s, but that just gave...

Ruby on Rails: Xpath: Could not retrieve XPath

This is the error I get: NativeException: java.lang.RuntimeException: Could not retrieve XPath >//id[@class='open'//@id='status_open']< on HtmlPage(http://cucumber.test.com/proposals/view-me/edit#)@17325460 (Culerity::CulerityException) This is my Cucumber command Then the "li" tag with the id "status_open" should have the class "ope...

Ruby on rails: virtual method that modifiyng model attributes with help of << couldn't save that attribute

There is model Ratification with attribute comment (of type text) def Ratification < ActiveRecord::Base attr_accessor :add_comment def add_comment=(text) self.comment ||= "" self.comment << "\r\n" + text end end And if I use add_comment= it is ok before I save the object. After save comment changes was dropped. >> r = R...

retrieving text in selenium using xpath?

Hi i have this HTML code: <tr class="odd events" style=""> <tr> <a title="Expand to see Actions" class="toggleEvent" name="actions_for_host_1" href="#"></a> <td id="7" colspan="6"> <div> <ul> <li>Low Alarm at 2010/06/25 07:09 ( <span title="2010/06/25 14:09 (UTC)" class="time_helper">Pacific</span> )</li> </...

How can I read directory or file information using Ruby/Rails or possibly PHP?

Hi, I need to reprocess some files using attachment_fu, but not all of the files. I've seen a few posts asked about reading and listing files in a directory using Ruby, but does anyone know how to select the files based on the upload date or file parameters? I can use either the date parameters for when the file was uploaded or loo...

Ruby on Rails: Interpreting a form input as an integer

I've got a form that allows the user to put together a hash. The hashes desired end format would be something like this: {1 => "a", 2 => "x", 3 => "m"} I can build up something similar by having lots of inputs that have internal brackets in their names: <%= hidden_field_tag "article[1]", :value => a %> However, the end result is t...

Can acts_as_ferret be used without the DRb server?

I'm considering AAF for a Rails project, but there seems to be quite a bit of chatter that gives AAF a reputation for being very buggy & unstable. From what I've been able to determine, most problems result from multiple processes trying to write to the Ferret index, but I've not been able to determine whether problems also result when...

Filtering results in rails with multi-valued checkboxes

Hello, I'm attempting to create a filter on a rails application that uses multiple check boxes corresponding to one db-column/attribute to filter through results, but I'm not sure how to go about it exactly. EX. index shows a list of the last few years' weather and you want to filter through it These attributes would be part of a Day c...

Questions on nested resources in Ruby on Rails

How can I specify a custom action for a nested URL in ruby on rails? For example, I have two resources people and book. In the book controller, I have a custom action, say foo_action. I am wonder how can I use nested resources in ruby on rails to specify something like: people/10/book/foo_action/20 basically, call the foo_action asso...

Ruby on Rails: Best way to fill out a model Hash or Array field?

I've got a model that has a serialized hash as a field. I'm trying to create a form that enables users to fill this out. Is there a way to use Rails form_for helper to concisely build the hash? The model is an Article, and an Article can have many authors which are stored in a serialized hash. class Article serialize :authors, Hash e...

Ruby on Rails: Cucumber: how do I test if a link opens in a new window / tab?

I have a preview link in my app, and it opens in a new window, so that you don't lose any unsaved changes... how do a divert cucumber's attention to the new window? ...

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 ...

Error Pushing To Heroku, Rails3 beta4

hi, i'm getting an error when pushing to heroku using rails 3 beta 4. i've managed to deploy before using it but for some reason i'm getting a strange error now. I'm on os x, snow leopard. I've been using rvm with both 1.9.2 preview and head, i also just reverted back to the system ruby 1.8.7 -p254 but they all give me the same err...

Initializing active record model using invalid parameters

I have a model that contains a country_id and region_id. The form posts back the name of the country and region (as params[:country] and params[:region]) instead of the ids. This creates a problem when calling 'new'. Is it possible to add code to the model so that the countries and regions can be located by name? I am currently doing it ...

MongoMapper, increment and update other attributes at the same time?

How do I do the following in one operation: Find or create object by some key:value pairs Increment properties on the object. I am doing this now: Model.find_or_create_by_this_and_that(this, that).increment("a" => 1, "b" => 1) What's the correct way to do that? ...