ruby-on-rails

How to strip html tags out of xml generated by builder in rails

Here is my situation. I'm trying to create a valid rss feed for an itunes podcast from an existing project. It's a rails application that allows uploading of mp3 radio shows to for listening on the site. I want to take all entries in the database and create an rss feed out of it. I'm using a builder file and everything is working fin...

Rails: Is it better to send email notifications from a model or a controller?

Assume mailings are sent of to be processed later (i.e. through starling or delayed_job). What I want to know is its a better practice to send email notifications from ActiveControllers or ActiveRecords? I guess its useful to put it in the controller since you might want to control whether an email SHOULD be sent or not (i.e. after a m...

Rails 3 - When loading a partial how to Combine a String (comment_) with a variable

I have the following: commentable.id =3131 In the partial: <%=f.text_area :content, :id=> 'comment_content_' commentable.id %> I want it to make: <textarea id="comment_content_3131" /> How do I combine the string with a variable in the partial? Thanks ...

Rails3 subdomain routing

I am trying to port over my Rails 2.3.5 app to Rails 3, and having trouble with the following route configurations: ActionController::Routing::Routes.draw do |map| map.app '', :controller => 'projects', :action => 'index', :conditions => {:subdomain => true} map.with_options :controller => 'site', :action => 'page', :sub...

Any suggestion on handling unwanted text in a textfield in ruby on rails?

Ok so i have this problem i am trying to address. I have this textfield with the id of request_money <input id="request_money" name="request[money]" size="30" type="text"> In this textfield i have a watermark plugin that i am using with the text "Not now" which is happening via jQuery $("#request_money").Watermark("Not Now"); This ...

Objects don't appear in test database when running specs

When saving an object by calling Entity.create(:name => "Entity1") from the Rails console in the testing environment (RAILS_ENV=test rails console) the "Entity1" object correctly appears in the test database (MySQL) when checking it with a mysql client. But when doing the same stuff in an rspec file (entity.create(:name => "Entity1"); sl...

Does rake db:populate work in Rails 3?

I'm having huge problems with my populate.rake file - after importing my existing file from my Rails 2.3.5 installation, Rails 3 wants nothing to do with it. I'm getting tens (if not hundreds) of errors in my console, many of them for simple statements, and some even in the middle of a string of plaintext. Has the syntax changed for Rai...

rails workflow gem method missing error state machine

Hi, I am having a bit of trouble with the 'workflow' gem, namely, the transitions aren't working. What I am trying to do is very basic, I have a 'read/unread' state for messages between users, the transition is triggered when the user goes to a 'show' page for that specific message. However, I can't seem to get the transition to wor...

Rails see generated queries in log

Is there a way to see all generated queries from rails in production environment like you can in development? ...

how can I make sure a day is a weekday in Rails?

I have a message substitution called next_week which basically takes Date.today + 7.days. However, although I still want to send emails on weekends, if the next_week falls on a weekend, I want it to know this and push to the Monday. How do i do this? ...

Finding an array element by id in Rails

I am a Rails newbie (from PHP). So forgive this basic data structures question: In the controller: @games = Game.all @players = Player.all In the view: <% @games.each do |game| %> <%= game.player_id %> <% end %> When iterating over the @games, instead of displaying the player id with game.player_id, I'd like to display the play...

Turn off transactional fixtures for one spec with RSpec 2

How do I turn off transactional fixtures for only one spec (or Steak scenario) with RSpec 2? I tried some things found on the web without any success. This leads to an undefined method exception. describe "MyClass without transactional fixtures" do self.use_transactional_fixtures = false ... end This simply does nothing (transac...

How do I generate pdf file using Prawn in Rails?

I have used the following syntax to generate a pdf file: Prawn::Document.generate("#{RAILS_ROOT}/public/pdf/generate.pdf") do pdf.text "hello" end But when I look for the file within the /public/pdf/ folder, I dont find any file. Well my controller code for this is def generate ...

Testing JQuery UI autocomplete with Capybara + Env.js does not work (with Selenium it works)

I do an RSpec integration test of the JQuery UI autocomplete functionality by using Capybara. When using Selenium (+ Firefox) as the web driver for Capybara everything works as it should, but when switching to Env.js as driver my tests fail. Are those known shortcomings of Env.js, or do I miss something? ...

Swiching between open windows in Netbeans

Hi, is there any way to switch between open windows like for example in gnome terminal (Alt+1, Alt+2,...). C+` is no comfortable for me. ...

Port Forward Directly to a Guest OS with VirtualBox

Hi all, I am currently using Ubuntu 10.04 for some rails development. It is installed as a guest machine using VirtualBox on a Windows 7 x64 host. Within Ubuntu, I am trying to port tunnel several ports from a remote server directly to the Guest OS in order to avoid having to download a remote database. Let's say I want to forward po...

Rails Routes Namespaces and form_for

I have namespace in my routes.rb namespace :businesses do resources :registration end My controller is in a subdirectory businesses/registration_controller. def new @business = Business.new end In my view, I want to do this form_for @business do |f| ... but I am getting the following error: No route matches {:controller=...

How do I delete mongrel temp files after completion of upload?

Hi all, In my rails application am uploading some large file(1 Gb),and when I go windows temp folder, mongrel temporary files are gathering there, but I would like these files to be deleted after upload completes. Could anyone tell me how do that?? This is my ruby version: ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32] ...

Why was assert_template deprecated, and what should I use instead?

According to the documentation for assert_template, it's deprecated. Why was it deprecated, and what should I use instead? ...

Online Payment solution to account to account transfer

Hi, I would like to know if there is a possibility of transferring money from my sellers customer to my seller directly without me getting involved? Setup is like this I've my website Sellers register and sell their items Customers register and buy sellers items.. What i want is to take money from customers account (be it credit ca...