ruby-on-rails

will_paginate without use of activerecord

I apologize if this is a trivial question or my understanding of rails is weak. I have 2 actions in my controller, index and refine_data. index fetches and displays all the data from a database table. refine_data weeds out unwanted data using regex and returns a subset of the data. Controller looks like: def index Result.paginat...

Create an array of countries and display them in a select box

Hello, I am new in Rails and I am trying to put countries in array and then display them in a select box. My array looks like this: country = {} country['FR'] = 'France' country['UK'] = 'United Kingdom' Any ideas? ...

How best to deploy DokuWiki within my Rails application?

I would like to install DokuWiki within my Rails application at domain.com/wiki Would it be best to unzip and install it in public/wiki? I don't want to have to commit/push/pull DokuWiki pages every time I'm working on my application. Would you suggest telling git to ignore the wiki directory entirely? or is there a better way to do th...

collection_select and not being submitted database

I have a small problem and it is really bugging me. I have all the standard scaffold code in the controllers to give me the standard CRUD features. The collection_select form helper is in my view: <%= collection_select(:link,:category_id,@categories,:id,"name") %> The Link Table has a category_id column. This is being posted ok,...

RUby on Rails nested dynamic fields

Hi guys! I have a problem to find the right way to program dynamic fields. For example: I have two radio buttons and depending on how the user selects one radio button, it extends the form with different fields. Start form: - Radio button: car - Radio button: ship - Text field: name If the user clicks on the radio button "car" the for...

apply fieldWithError to a label

Hi i have a form with rails validation. When a field have an error rails apply the fieldWithError class only on the input with a certain id. I want to apply the class fieldWithError also to the label. Is possible do it? thanks ...

db:migrate creates sequences but doesn't alter table?

Hello, I have a migration that creates a postres sequence for auto incrementing a primary identifier, and then executes a statement for altering the column and specifying the default value: execute 'CREATE SEQUENCE "ServiceAvailability_ID_seq";' execute <<-SQL ALTER TABLE "ServiceAvailability" ALTER COLUMN "ID" set DEFAULT NEXTV...

Breadcrumbs in Ruby on Rails

Hi, I'm slightly insecure about my breadcrumb solution. Names and links are defined in each controller action: <a href="http://localhost:3000/"&gt;Home&lt;/a&gt; <% if defined? @l1_link %> > <a href="<%= @l1_link%>"><%= @l1_name %></a> <% if defined? @l2_link %> > <a href="<%= @l2_link%>"><%= @l2_name %></a> <% end %> <% end ...

Display a value according to ahash-table in Rails

Hello, In my database for a column called 'how_get' I can have a value of 1, 2, 3 and so on... so in my view to display the data I use: <%=h @offer.how_get %> and I get the value displayed 1, 2.... but what I would like ti to have a hash-table with values like this: @how_d = {'By train' => '1', 'By car' => '2'} so instead of '1' ...

RMagick with ruby on rails , Reset Original picture

I am using Rmagick in my photo sharing application and Its working properly , but while editing the picture ,my original picture get lost, I can't RESET the original picture , my code is given below . image = Magick::ImageList.new("public/"+ @upload.public_filename(:org)) # image = image.colorize(0.30,0.30,0.30,"orange") if params[:met...

Testing multiple concurrent browser sessions

I'm developing a card-game in Ruby on Rails, and trying to work out how best to test it. When a player joins a game, their Player object is stored in the session. Obviously, in order for the game to work, I need more than one Player in a game at once. Since sessions are the same for different tabs in one browser, I'm currently testing ...

Use :include statement to find records

I'm working on Ruby On Rails 2.3.2 and I'm learning how to use the :include statement. I'd like to get all the announcements order by their rate. I've got two models and tables for that: Announcement and Rate. The models look like this: class Announcement < ActiveRecord::Base belongs_to :rate end class Rate < ActiveRecord::B...

Rails, routing many named routes to one action

Is there a simpler way of writing this: map.old_site_cusom_packages '/customs_packages_options.html', :controller => :public, :action => :redirect_to_home map.old_corporate '/corporate.html', :controller => :public, :action => :redirect_to_home map.old_track '/track.html', :controller => :public, :action => :redirect_to_home map...

Authenticating against a remote service using Authlogic

I need to allow users to login to spree using a non-standard authentication service. Users in my community all have accounts on another 3d party service set up for us. That service provides a web-service that takes a login and password, and returns a userId if successful. As an admin I can then query for user profile information. I've b...

i18n locale in the URL

Hi, I'd like to have all the url of my application with the locale, ex : http://domain.com http://domain.com/user/new to become : http://domain.com/en http://domain.com/fr http://domain.com/en/user/new http://domain.com/fr/user/new How could I do that without passing the locale in all my links ? ...

Rails3 server and bundler error: uninitialized constant Bundler (NameError)

I just install rails 3 and all gems that it need, but when I try to start server, it says about problem in boot script. [rap-kasta@acerAspire testR3]$ script/rails server /home/rap-kasta/tmp/testR3/config/boot.rb:7:in `rescue in <top (required)>': uninitialized constant Bundler (NameError) from /home/rap-kasta/tmp/testR3/con...

Rails shared restful authentication between multiple apps

I'm creating a rails app that will run on the same domain as an older app. I would like to be able to use the restful login functionality of the older app to authenticate users for the new app. Ideally, the user could login to the old app and then have access to the new app. I'm running two mongrel instances for each app. Any help is ...

How to disable postprocessing for pdf files in Paperclip?

Paperclip by default try to process every image file to generate thumbnail. But it also try to do it with pdf files, which can be really time consuming task. I tried looking on google and found one solution, but it changes Paperclip methods. How to disable pdf postprocessing in Paperclip without changing Paperclip sources? ...

How to access the joining model on a has_many :through relationship

I have a typical many-to-many relationship using has_many => :through, as detailed below. class member has_many member_roles has_many roles, :through => :member_roles end class role has_many member_roles has_man members, :through => :member_roles end class member_role belongs_to :member belongs_to :role # has following f...

Validating forms with variables

In most of the examples I see, I notice that in the controller, the new method simply has: @object = Object.new In the create method, you'll see something like: @object = Object.find(params[:object]) if @object.save flash[:success] = "This object has been added." redirect_to objects_path else render :action ...