ruby-on-rails

Ruby on Rails Routing Error

Hi, I was developing the Application in Flex and ruby on rails. It is working fine some times. but some times i am getting routing error. Error: "No route matches "/index.html" with {:method=>:get}" Here index.html is my login page Please help me on this. Thanks, Ravi ...

How to call 'time_ago_in_words' from a FunctionalTest?

I'm using 'time_ago_in_words' function in a view, and I need to test the output in the FunctionalTest. But the test can not see 'time_ago_in_words' helper function. What should I do in order to use these helper methods from FunctionalTests? ...

Rails transaction doesn't rollback on validation error.

I have two models: user and company. They both get created from one form and I'm using a transaction like this: User.transaction do @user.save! @company.user = @user @company.save! @user.reload @user.company = @company @user.save! flash[:notice] = "Thank you for your registration." redirect_to_index end The user g...

How do I build a gracefully-degrading HTML5 Range?

I'd like to use the <input type='range' /> from HTML5 for browsers that support it and degrade to a <select /> if not. I'm using Ruby-on-Rails, so failing all else, I could do something like this on the server-side. I would prefer, though, to have something more inline with the idea of progressive enhancement done via Javascript. Bonus ...

puts vs logger in rails rake tasks

In a rake task if I use puts command then I see the output on console. However I will not see that message in log file when app is deployed on production. However if I say Rails.logger.info then in development mode I see nothing on console. I need to go to log file and tail that. I would ideally like to use Rails.logger.info and in dev...

is there a way to make a DB diagram based on rails migrations?

is there a way to make a DB diagram of tables..columns and their relationship based on a rails app? if not...are there tools that would do that for a postgresql DB on ubuntu? ...

RoR - Images in DB tables?

I want a user to upload multiple images (+ thumbs) and give a description about their pics. What do i need to do to create this the ruby way? Do i manually create the tables (and which are these) or what gem do i require? I want to store the file physical on a path and store the link (+ attr. information) in the db (if it is the best s...

Using Rails commands with a disabled command line

I'm using a public Windows computer where the command line has been disabled. By using Instant Rails I'm able to create customize and test rails apps to some degree but can't use the Rails commands. Question: How do I use these commands with a disabled command line? I've tried using SciTe, Notepad++ but all these just access the same ...

Rails keeps being rebooted in production Passenger

I'm running an application that kicks off a Rufus Scheduler process in an initializer. The application is running with Passenger in production and I've noticed a couple weird behaviors: First, in order to restart the server and make sure the initializer gets run, you have to both touch tmp/restart.txt and load the app in a browser. At t...

Using Rake on a gem with dependencies

I have a gem that requires a 'Cms' namespace to be present when running. However, when running rake tasks, nothing works as this Cms namespace isn't present. How do I get my rake tasks to work? ...

RoR - Account - Login - Register + ...

Is there an automatic way in Ruby On Rails for authentication porpose? What gem is this and what does it do? Does it automaticly generate the tables and pages like when i should generate a scaffold? ...

Creating "feeds" from multiple, different Rails models

I'm working on an application that has a few different models (tickets, posts, reports, etc..). The data is different in each model and I want to create a "feed" from all those models that displays the 10 most recent entries across the board (a mix of all the data). What is the best way to go about this? Should I create a new Feed model...

Rails: How do I use a javascript variable outside <script.../> but inside the view?

In a view I have a script (javascript) that declares a variable after some deep processing. How can I use that variable outside the script boundaries in the same view page? some_view.html.erb <script>var seq = Sortable.sequence('list');</script> # How to do this? Is it possible? <%= sortable_element "list", :update => "order", :c...

Find user by authentication token in Rails?

So for a certain project I'm thinking it may possibly be useful for me to be able to take an authentication token and figure out which user it is for. I'm not sure if it's even possible or not. Anyone happen to know? ...

Link_to_remote with Nested Routes

I'm trying to figure out how to structure my path on a link_to_remote tag to accommodate nested routes. I have an article model that belongs to a group model, and the article has votes associated with it (using the Vote_Fu plugin). I created the code for articles first and it worked, but in the process of adding the group model and updat...

Rails .scan won't work with a model variable using nokogiri

Hello, I 'll try to be as explicit as possible I am using nokogiri to parse links from paths and rules out of a database I have this model: --- !ruby/object:Content attributes: id: "2" name: http://www.****** try description: try url_base: http://www.****** scan_flv: /"file","([^<>]*flv)"\);/imu source_site_id: "2" con...

How do I change Webrick server root?

Where is the “scripts/server” file that bootstraps WEBrick and tells where WEBrick should serve files from? ...

Upgrading Cybersource SSL certificates in existing Rails application

I recently inherited a Rails site that uses ActiveMerchant for e-commerce transactions through CyberSource as a merchant gateway. A few days ago, I received an email from CyberSource informing me that CyberSource's SSL authority, Entrust, is mandating the use of higher-strength SSL certificates, and that in order for SOAP API calls to b...

Rails: With models A has_many B belongs_to C return A where B belongs to C and B is most recently created for given A?

I have three models A, B, and C, where A has_many B; B belongs to C, and B has a created_on timestamp. C has_many A through B. I want to return all A where A has a B that belongs to C and where B is the most recently created B for that A. I can do this with a method loop. Can this be done solely with named_scopes?, or is some other ...

Action caching is not expiring correctly, even when I can see it's being called.

Hi there, I've got a sweeper that's supposed to expire a few action caches. Even though the debugger stops immediately before the call to expire_action, it's not actually expiring the action. Any idea what could be going on? Here are the relevant sweeper and controller. #company_sweeper.rb (in 'models' directory) class CompanySweeper ...