ruby-on-rails

Preview after edit, before saving

Hi, I'm trying to think of a way a user could make changes to a record that includes changing the picture (added via paperclip), preview the changes and then accept or cancel. Is there any way to do this without using temp tables as the image cannot be rendered without a path linked to an id? ...

Rails Home Index file not generating (or supporting files)

When I run in terminal: rails generate controller home index This file, "app/views/home/index.html.erb." is not generated. I did get what is below. . . . ======= > > generate controller home index > create > create app/controllers > create app/helpers > create app/models > create app/views/layou...

How to send xml or image data from iphone to a rails 3 server ?

Hi guys, I am developing a hybrid app (rails 3 + iPhone) and I want to send a number of large strings and images to a rails 3 server. I want to do a POST method from iPhone. Can someone help me on how to do this ? since in this case there will be no form in the views how should I accept the data ? Thanks in advance ...

Sqlite on a production box

Should I have to install sqlite on a prod box where I'm using mysql for a rails application? The reason I ask is that phusion is yelling at me with the following error: Could not find gem 'sqlite3-ruby (>= 0, runtime)' in any of the gem sources. (Bundler::GemNotFound) My gemfile has the following group :development, :test do gem...

accepts_nested_attributes and validates_uniqueness_of

The central problem: How do you merge attribute collections by a key during mass assignment from a nested form. The details: I am using the following models: class Location < ActiveRecord::Base has_many :containers, :dependent => :destroy, :order => "container_type ASC" validates_associated :containers accepts_n...

Running old site on apache + php and new nginx rails side by side

Hi all My current site is running on a dedicated server on apache + php. I am creating my new site in rails and running on nginx. I want to run both sites together for a while while i slowly redirect all pages SEO rank etc to new site. My current site has say domain www.mydomain.com and new site will have www.mydomain.com/en infront ...

conditionals in Gemfile

Our team uses different databases for each other, and we are using bundler so our Gemfile contains the repo creator's db connector(mysql) I am using pg and due to a bit laziness and fear of breaking something, I don't want to use mysql, so I just add a gem "pg" in our Gemfile. Of course, since we're using git, it will always show as a ...

How can I open multiple concurrent sessions with cucumber, capybara, and selenium?

I'm fixing up some old integration tests for our (RoR 2.3.5) website, and some scenarios (and their behaviors) depend on having multiple users logged in simultaneously. Once upon a time, these worked... three engineers and 18 months ago. Our basic scenarios are written in cucumber, with capybara binding to selenium. I've tried all of t...

Rails many-to-many fields_for: How to access fields_for values?

Hi folks, I'm trying to created a set of nested (many-to-many) forms in rails 3. Everything works fine thanks to fields_for, but I need to put a title above each nested form. That title has the value of the profession_type.name field (which has a prepopulated value) in each respective nested form. I'm having a heckuva time extracting t...

Rails 3 Clone ActiveRecord Model with Submodels

Basically I have two chains of models, one holds 'predicted data' and one holds 'actual data'. I would like to copy all predicted data to actual when an actual is created. def init_data employees = Employee.all employees.each do |e| t = e.template ed = t.effective_dates.first if ed and !e.routes routes = ed.routes....

The {{key}} interpolation syntax in I18n messages is deprecated. Please use %{key} instead.

I am running ruby 1.8.7 (2010-01-10 patchlevel 249) [i686-darwin10.3.2] with Rails 2.3.8 and I have to use that version. When I run 'rake test' I get The {{key}} interpolation syntax in I18n messages is deprecated. Please use %{key} instead. There was a bug but now should be solved: https://rails.lighthouseapp.com/projects/8994/ticke...

Thinking Sphinx not indexing associated data to model searched by.

In my Product.rb define_index do indexes :name, :sortable => true indexes brand has :id, kosher_id, gluten_free_id, lactose_free_id has stores(:id), :as => 'store_ids' has locations(:id), :as => 'location_ids' has categories(:id), :as => 'category_ids' has kosher(:passover), :as => 'kosher_passover' end ...

Partially updating a model in Rails 3

I'm new to rails and have a simple problem. I have a rails model: class User < ActiveRecord::Base attr_accessor :password attr_accessible :name, :email, :password, :password_confirmation, :description email_regex = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i validates :email, :presence => true validates :name, :presence =>...

Why is this SQL generating a temporary table and running so slow?

Hi, I have the following SQL generated from my Rails app, it is trying to get a list of all auto models that have live adverts in a marketplace app & from mysql: SELECT `models`.* FROM `models` INNER JOIN `autos` ON autos.model_id = models.id INNER JOIN `ads` ON `ads`.id = `autos`.ad_id WHERE (ads.ad_status_id = 4 AND pub_start_...

NoMethodError in Users#show

I'm following the rails tutorial @ http://railstutorial.org On chapter 11, I'm having issues with showing microposts from users. Based on the tutorial, the RSPEC test should pass. However, it fails 1) UsersController GET 'show' should show the user's microposts Failure/Error: get :show, :id => @user undefined method `model_name'...

Create new records on before_save.

While creating new records. I need to create more records for the same model. Example :: class XYZ < ActiveRecord def before_save # At this point object is already initialized .. # And it's containing values. # At this point i want to create 10 more records for the same class. # something like this XYZ.new(:att1 => valu...

Rails - Find By with 2 fields?

Hello, I have the following in a controller def update @permission = Permission.find_by_user_id(params[:user_id]) But I want it to also find by another param, project_id How can I do something like this in Rails? @permission = Permission.find_by_user_id_and_project_id(params[:user_id],params[:user_id]) Thanks ...

Seg Faults trying to run Memcached?

I'm having tons of problems with Memcached. It seems to be installed fine locally, I can run the command 'memcached -vv' and see that it's listening. I'm deploying to Heroku (which has this section: http://docs.heroku.com/memcache on using memcached) and definitely have the memcached add-on installed. Here's how my environment is set up:...

Rails 3 - Using form Params in a controller's Update?

I have the following form: <%=form_for [:project, @permission], :url => { :action => "update" } do |f| %> <% roles = Role.all %> Role: <%= f.collection_select :role_id, roles, :id, :name, :prompt => true %> <%=f.submit "Send Request" %> <%=f.hidden_field :user_id %> <% end %> In my controller I have: def update @permission = P...

Don't reshow seen posts in Rails

Hi, I'm currently developing an application whereby a user clicks a button and they're offered up a new page of content, and was wondering how I would go about hiding or skipping past those that the user has already interacted with (a separate table stores the post_id and user_id for each view). I currently use this code in the model fo...