ruby-on-rails

how do I speed up netbeans' localhost?

I've just switched from radrails to netbeans. So far, so good. But I have noticed that radrails used to serve up pages a lot faster on localhost. I've left the server on glassfish, what can I do to make it run faster I'm on windows xp ...

Showing a spinner during an AJAX request?

Hi, what is the best way to show a spinner? I have prepared a div(id="spinner"), that should be visible during loading. Best regards ...

How to have autotest and RSpec nicely formatted when comparing long texts (with \t and \n)?

I have a test in RSpec which compares to long text strings. When the test fails, I get a message like this: 'jobs partial should render the correct format for jobs' FAILED expected: "Job {\n\tName = \"name1-etc\"\n\tType = Backup\n\tMessages = Daemon\n\tPool = Default \n\tSchedule = \"schedule1\"\n\tStorage = storage1\n\tClient = \"name...

Rails ActiveRecord :joins with LEFT JOIN instead of INNER JOIN

I have this code User.find(:all, :limit => 10, :joins => :user_points, :select => "users.*, count(user_points.id)", :group => "user_points.user_id") which generates following sql SELECT users.*, count(user_points.id) FROM `users` INNER JOIN `user_points` ON user_points.user_id = users.id GROUP BY u...

how to iterate within a state machine?

I am implementing a wizard like interface which will help a user configure application settings. I am using the AASM plugin to guide the user from state to state with the ability to go forward or backward through the configuration. I have implemented a skeleton of this core functionality and it is functioning as expected. The problem I...

rails how to call another controller in link_to_remote

how to call a different controller's action using link_to_remote :url => {:controller => "Posts", :action => "update"} doesn't work ...

Is there any framework like RoR on Python 3000?

One of the feature I like in RoR is the db management, it can hide all the sql statement, also, it is very easy to change different db in RoR, is there any similar framework in Python 3000? ...

Using link_to_remote inside of a controller

Hello, how can I use link_to_remote inside of a controller? I have already included ActionView::Helpers::JavaScriptHelper, but still get the error: undefined method `content_tag' Thanks! ...

How do I get the base URL (e.g. http://localhost:3000) of my Rails app?

I'm using Paperclip to allow users to attach things, and then I'm sending an email and wanting to attach the file to the email. I'm trying to read the file in and add it as an attachment, like so: # models/touchpoint_mailer.rb class TouchpointMailer < ActionMailer::Base def notification_email(touchpoint) recipients "[email protected]...

Ruby On Rails Routes Problem

Hi Guys, I am have started learning Rails, it was going good until now. I am using HAML and have this on my index.haml = submit_to_remote "submit_btn", "Create", :url => {:controller => "queries", :action => "create"}, :method => "post" = submit_to_remote "exe_btn", "Execute", :url => {:controller => "queries", :action => "execute"},...

Mocha + Cucumber to mock the Net response

The following is the app/models/websites.rb class Masterpiece < ActiveRecord::Base validates_presence_of :title, :link validates_uri_existence_of :link, :allow_redirect => false end The second validation is from the plugin Validates Existence of URI plugin The following is the features/support/mocha.rb file require 'mocha' W...

Single query for all records having no key in a join table and those having a matching key

I have a trip that has many residencies. I need a single query that returns all trips where no residency information has been specified. And all trips that match a specified residency. I can get the first from this query: SELECT * FROM `trips` WHERE (((NOT EXISTS (SELECT id FROM residencies WHERE trips.id = residencies.trip_id)) Bu...

How to tell ruby net libraries to use a particular network interface?

Hi, I'm doing some page scraping for a client and need to connect to their vpn server. So I have the vpn client running on my linux box, and this creates a new interface, say ppp0. Now, when I run Mechanize/open-uri, etc. I need to be able to bind specifically to this particular interface, because the other interfaces are to the intern...

How can I use ActiveRecord on a database that has a column named 'valid'? (DangerousAttributeError)

I am accessing a database that I can't change and it has a column named valid defined. Anytime I try to access an attribute, I get this exception: valid? is defined by ActiveRecord (ActiveRecord::DangerousAttributeError) The exception makes sense, but since I'm not able to change the database, how can I get around this error? I tried ...

How to do HABTM management with auto completion in Rails?

I am looking for a good solution for a probably typical problem of managing models with HABTM association in Rails. Let's assume that we have two models -- products and categories: Products has_many :categorizations has_many :categories, :through => :categorizations Categories has_many :categorizations has_many :products, :thro...

How do I limit the size of a Net::HTTP request?

I'm creating an API service which allows people to provide a URL of an image to the API call, and the the service downloads the image to process. How do I ensure somebody does NOT give me the URL of, like, a 5MB image? Is there a way to limit the request? This is what I have so far, which basically grabs everything. req = Net::HTTP...

before_filter running multiple time and growing

Hi, I have this funny situation whereby I see my before_filter executing multiple times for one access. My filter is called auth_user_filter and it logs using logger.info("Yada Yada Yada"). It gets set globally to run before all actions. When I access an action over my browser it prints the following (depending on what call it is) The...

How to block javascript evaluation during updating a page

Hi! I am updating a page through AJAX using .rjs template. Is there any way to block evaluating javascript in rendered content (something like :script => false for link_to_remote)? My update.rjs looks pretty much like this: page.replace_html 'some_div', :partial => 'partial_with_js', :collection => @list page.insert_html ... (etc.) ...

Call a method in model after find in Ruby on Rails

Hello. I would like to know if it is possible to call a method from a model after using find. Something like after_save, but after_find. Thank you, Gabriel. ...

Best Rails/Ajax Effect/Animation Library

What javascript effect/ui libraries are the best that also have Rails helpers and all that? Which ones do you use. Seems like people use jQuery with either scriptaculous or yui for the interface elements... Is there anything that's particularly easy or best that's supported in a Rails gem or something similar that you recommend? ...