ruby-on-rails

How do I sum up a column in a spreadsheet created by using spreadsheet gem by using a formula.

I have a spreadsheet where i want to sum up a column values. The Spreadsheet::Formula has a very weird documentation. Is Formula supported or should I sum a column by summing up the values of the cells in a column? ...

Switching from form_for to remote_form_for problems with submit changes in Rails

Hi there, another day with Rails and today I want to use Ajax. linkt_remote_link for changing a text was pretty easy so I thought it would also be easy to switch my form_for loop just to an ajax request form with remote_form_for, but the problem with the remote_form_for is that it doesn't save my changes? Here the code that worked: <%...

paperclip error

i am trying paperclip for the first time and followed this tutorial all is well until i use styles. this is the code has_attached_file :photo, :url => "/uploads/products/:id/:style/:basename.:extension", :path => ":rails_root/public/uploads/products/:id/:style/:basename.:extension", :styles => { :thumb=> "100x100#" } the error i se...

Ruby Hash.merge with specified keys only

I'm pretty sure I saw on a Rails related site something along the lines of: def my_function(*opts) opts.require_keys(:first, :second, :third) end And if one of the keys in require_keys weren't specified, or if there were keys that weren't specified, an exception was raised. I've been looking through ActiveSupport and I guess I might...

How to disable caching in Rails by IP address?

I was used caches_page/caches_action for some page, it set expire in a time(1 hour or 1 day), I don't expire cache when the data updated. When the editors create or update the content them can't view the new result in the page. I want to disable the global caching when the visitor IP in my company. How to do it? ...

How to correctly set up routes when creating a new view in Ruby on Rails?

I created a new action called "asked". asked.haml is in views/questions as it should be. I've also added def asked respond_to do |format| format.html format.xml { render :xml => @questions } end end to the Questions controller for this action. My problem is that when I got to the url http://localhost:3000/q...

Please suggest some alternative to Drupal

Drupal propose completely different approach in web development (comparing with RoR like frameworks) and it is extremely good from development speed perspective. For example, it is quite easy to clone 90% of stackoverflow functionality using Drupal. But it has several big drawbacks: it is f''cking slow (100-400 requests per page) db st...

how to expand spinner time?

how to expand spinner time ? ...

Beginner Ruby / MSQL Error

http://localhost:3000/genre I'm using Instant Rails, I'm introducing scaffolding for the first time ever. So everything looks like its working fine, I did my own RoR page etc, today i come in today and when I go to localhost:3000 I get the following error message: Oops! Google Chrome could not connect to localhost:3000 Any suggestion...

Problems running Ruby on Rails apps on shared hosted server

I have problems installing any Ruby On Rails app on my shared hosted server. Mongrel shows html as plain text for all pages. The problem occurs for any app, even if I create a test empty app and add a scaffolded view without changing anything. It appears that the Mongrel crashes when trying to put cookies to the response header. The HTT...

rails named routes + controller as parameter

Hi, is it possible to have the controller value in a rails named route as a parameter, which I can pass at runtime to direct the call to the proper controller? e.g. map.ride 'ride' ,:controller => {some-way-of-specifying-a-parameter}, :action => 'ride' then at runtime, I want to pass the controller name to which this call should be goi...

Rails select box.Cannot set default value as 'All' .

Just pressing on search button without select items from the select box , all records should appear. <%=select("item", "item_priority_id", ItemPriority.all.collect {|p| [ p.name, p.id ] },{:include_blank => 'All'},{:multiple=>true})%> problems of the above existing code are: default 'All' will not work ie, it will give 'No Records' ...

Test if current page is inside a shadowbox? (so i can close the shadowbox and reopen that page in the main window)

Hi all I have a couple of pages in my site which open in a shadowbox window rather than the main window. My problem is that if the user session expires, then the user clicks on one of the links that open in a shadowbox, they are redirected to the login page INSIDE THE SHADOWBOX, which i don't want. I've been trying to think of the bes...

What's the use of has_one :through here (example from Rails guide)

Why they are using has_one:through here. We can do the same with has_one only. What's the need of making a new class. Can you give me any good example? Here is the link for the original example from Rails guide EDIT We can do the same thing in this way what's the use of making it a has_one:through class Supplier < ActiveRecord::...

'Illegal mix of collations' error (Ruby on Rails)

I'm trying to write a screen-scraper for a Rails app, scraping this page. Bit new to Rails, SQL and everything else really. According to the W3C validator, the page I'm scraping is encoded as iso-8859-1. My database is Latin-1. Just to be sure, when I get the value I need, I save it as Latin1: value = Iconv.iconv("latin1", "iso-8859-...

Rails: Formtastic: Select-Boxes without primary blank field

Hi, it's about Rails and Formtastic. How can I add a select box with formtastic without an initial/primary blank field? So that the initially selected item is the first item with content. Thanks! Yours, Joern. ...

appending <a href> to keywords in rails

Basically, there are some keywords that i want to pick out and assign a link to them dynamically. How should i go about in doing this? Let's say i have something like this; <p>ruby, rails, php, python, django and sinatra</p> and i would like to assign links to keywords like ruby and python, so the end results should look like this; ...

RoR Beginner Routing error

I've created a DB and a table within that DB called genre. Now when I try to connect to this using the URL, I get the following error message: Routing Error No route matches "/genre" with {:method=>:get} Thanks for your help in advance. ...

getting strange loading time reports while trying to speed up rails app

i am using newrelic (developer mode) for monitoring my rails application. strangely, loading the same page gives different loading results with one random part constantly overweighing the rest. as an example (all results from same page, "messages/1", just doing a refresh) Exclusive ...

Find by Quantity

Let's say I have a model Vehicle and it has_many :wheels What is the correct find / :conditions => ... statement to find only vehicles with 3 or more wheels, e.g. tricycles, cars, trucks, tanks etc...? ...