ruby-on-rails

How can I simulate the browser back button in Capybara?

We have a issue on our e-commerce site where users occasionally hit "checkout" twice and have their card charged twice. It's a common enough bug and easy to fix, but I'd like to test the solution in our capybara setup. Once I've called click_button('checkout'), is it possible for me to pretend I'm a user hitting the browsers back button...

how to call javascript function in select_tag

<%= select_tag :per_page, options_for_select([10,20,30], @per_page.to_i), :onchange => "get_per_page_url(#{self.value})" this is code for calling javascript function in select_tag.but problem is that get_per_page_url function is calling here?? ...

How to configure an extra/different migrations folder

Hello. Me and a colleage are working in different projects that share some models. So, we are sharing the models thru a git submodule. Additionally, we'd like to be able to also share migrations: In this way, my collegue's migrations would be in the folder db/migrate/other_db of my project. How can I configure rails migrations to also...

Resque plugin's resque-web is not running.

Hi, I am using Resque and Resque scheduler,but when I am starting resque-web it is not running. And prompting an error " bash: resque-web: command not found". So how to start this resque-web on my local server. Thanks in advance. ...

Cucumber and Seed data

can we load seed data when start cucumber? Please support me a way. ...

Threading in Rails - do params[] persist?

Hi, I am trying to spawn a thread in rails. I am usually not comfortable of using threads as I will need to have a in-depth knowledge of Rails' request/response cycle, yet I cannot avoid using one as my request times out. In order to avoid the time out, I am using a thread within a request. My question here is simple. The thread that I...

Rails newbie: How to add routes to a rails 3 engine?

Hi folks, I'm trying to write my first rails 3 gem - everything works well, except for routes - I can't seem to get them working. It's possible this is a very simple error - as mentioned, it's my first experience with engines. The gem itself is very, very basic - literally just one scaffold My gem's config/routes file: class ActionCon...

Resque Scheduler plugin for the scheduled job not working.

Hi, I am using this plugin for scheduled job.But it is not working. I am confused about some points,Should I need to create the Job class and set their name in to schedule file?When testing it then,Should I run the rescue scheduler and Resque worker both or only one of them. Thanks in advance. ...

how to modify complex sql query w/ join into rails 3

I'm working on a car pooling application where users can add lifts and are able to select multiple stops for each lift ( A to B via c, d, e). Now when a user searches the database for a lift the results should also include lifts like 'A to d', 'c to B' or 'c to e' and so on. I got this working with Rails 2.3.5 using the below code but st...

Simple helper method - Am I doing it right?

New to Ruby and Rails. I am developing a simple app for where you can register teams, players etc and it looks like this: Team has_many Players Players belongs_to Team When I want to show the player in view(normal users): <%= @player.name %> - <%= playerteam %> and in the admin view it looks like this: <% @players.each do |player|...

Ruby: Find non-transparent PNG and convert into JPG

What is the smartest way to find out if a PNG has transparency or not in Ruby? Is it OK if I just check if there's an alpha-channel? If yes: How do I check for an alpha-channel? I'm writing a script that will convert all PNGs without transparency into smaller JPGs. Thanks a lot for your help! ...

Spree vs Magento vs OpenCart vs PrestaShop ?

I need to set up an online shop for my brother, I have no experience at all setting up an online shop, The number of options out there is overwhelming, Spree, Magento, PrestaShop, etc Is going to be an small shop (no more than 50 products), with a few custom features, nothing really complicate. I dont want to spend to much money in host...

i'm using passenger with apache and it cannot find my locally installed gems

if i use ./script/server my app runs fine but when i try to it it through passenger on apache it gives me Missing the Rails 2.3.5 gem. if i vendorize rails it seems that it finds it but then it fails for missing gems even though they are in vendor/gems. ideally, i would not want to vendorize rails or gems for such a reason, but woul...

CSS Navigation Drops only in Google Chrome. Rails Tutorial Feedback

I am going through the awesome Rails Tutorial http://railstutorial.org/chapters/filling-in-the-layout#sec:custom_css I've run into an issue with the Navigation dropping down into the body of the page, but this only happens in Chrome (I'm on Linux, Ubuntu 10.10 if that matters). Here is a screenshot and a URL to show you actually what the...

Rails 3: undefined method `remote_form_for'

I have a fairly simple Rails remote form in HAML in a partial under shared/users: - remote_form_for :user, :url => { :controller => "users", :action => "create" } do |f| .field = f.label :name, t('name') = f.text_field :name .field = f.label :email, t('email') = f.text_field :email .actions = f.submit No matt...

Rails: An efficient method to match subdomains in the database?

We allow users to add domains to an active record model such as User.domain and find the users by domain using User.find_by_domain. In the future we want to allow users to enter *.example.com as their domain and allow User.find_by_subdomain('sub1.example.com') and User.find_by_subdomain('sub2.example.com') to work. However we also want ...

Using RSpec, how to verify from tags and link tags in view pages?

In view pages, people use form tag helpers and link helpers etc. If I then rename a controller, or a action, my view pages may break. How can I unit test view related tags for this kind of a breakage? ...

How do I create this multidemsional Array, Hash Combo?

I have this data and i need an output like this type of output.. I basically need to have all the venues and their dates and all the songs associated to them ....if anyone can think of a better structure and how to achieve it I would be very thankful... { ["Vector Arena - Auckland Central, New Zealand" => { "2010-10-10" => ["...

Expiring memcached using mysql proxy when an update occurs?

Hi guys, I have mysql Proxy running which takes a query, performs an md5 on it, and caches the result into a memcached DB. the problem occurs when an update happens in the rails app that would invalidate that cache. Any ideas on how to invalidate all of the proper keys in the cache at that time? ...

CSV download fails with Internet Explorer on first attempt, works on subsequent attempts.

Hello, this has been throwing me off for too long.. Posted below is our Rails 3 controller. When attempting to access with Internet Explorer the first time, the download prompt fails with a "Unable to download" message. When attempting to access the same URL immediately following, the download prompt works successfully. In any instan...