ruby-on-rails

How should I persist order data over time without tying it to underlying product pricing data that is subject to change?

I have an application that processes and stores orders. Each order is composed of line items that have various things like pricing, sizing, colors, etc. My question is how do I persist that data over time without tying it to underlying data that is subject to change. For example, someone orders something which is composed of 5 thing...

Paperclip validates_attachment_content_type for mp3 triggered when attaching mp3

Hey everyone, Struggling to workout when i add the following validtion to my Voice model using paperclip, it is being triggered when i try and upload an mp3: class Voice < ActiveRecord::Base has_attached_file :clip validates_attachment_presence :clip validates_attachment_content_type :clip, :content_type => [ 'application/mp3', ...

I need to go from HTML to markdown, any suggestion?

I'm using Maruku, to convert from Markdown (superset) to HTML, do you know how can I do to convert from HTML to Markdown? ...

Can I disable some BackgroundRb workers during tests ?

I have a BackgroundRb worker in charge of dispatching some emails. How should I tell this worker not to run during tests? Does the framework include some configuration parameter or stub worker I could use? MiddleMan.worker(:emails_worker).async_send_mails(:arg => {:emails => emails}) ...

Fresh Rails install on Mac OS X gives me "Rails requires RubyGems >= 1.3.2"

I just set up a fresh Mac OS X 10.5 environment for Rails. I installed Ruby 1.8.7, renamed the packaged version of Ruby in /usr/bin, and updated the packaged version of RubyGems from 1.0.1 to 1.3.4. Here's the flow: $ rails -v Rails 2.3.4 $ gem -v 1.3.4 $ which gem /usr/bin/gem $ whereis gem /usr/bin/gem $ which rails /usr/bin/rails ...

Changing Current Tab in Rails

Hi All- I have a list of tabs at the top of my application that I include in a general layout in application.html.erb. They look like this: <li class="current"><%= link_to "Home", provider_path(current_user.id), :method=> "GET"%> </li> <li><%= link_to "Edit Profile", edit_student_path(current_user.id) %> </li> <li><%...

Rails migration generator not generating columns

Low sleep so probably missing something trivial, but... Based on various doc readings, I thought that this would generate a migration with table and column declarations included... $ script/generate migration Question ordinal_label:string question_text:string However, the result is... class Question < ActiveRecord::Migration def s...

Keep a table out of schema.rb during migrations.

As a follow-on to an earlier question about not reloading a huge, persistent table when I run my tests, I need to keep this table out of schema.rb when I run my migrations. This table gets loaded directly from a mysqldump, so I'm not worried about keeping track of it. So, how can I keep a specific table out of schema.rb? ...

Get tinyMce mode to activate on a new textbox inserted by AJAX (in Rails)

I have a nested attribute (speeches) under a model Speaker and I'm using tinyMce to let a speaker fill out a profile form where they might have one or more speeches they give. I'm using the Rails 2.3 nested attributes helpers as used in Ryan Bates's complex-form-example github account. The tinyMce functionality is great for a "Speech" ...

Rails - Too much logic in views?

I have an application used by several organizations and I want to check that users of one domain (a.domain.com) cannot edit users of another domain (b.domain.com). My question is where to put the logic, in a before filter or in the view? View: <% if @user.websites.detect {|website| website.url == request.host} %> render :partial => '...

Posting files to Rails XML API

I have a Rails application setup to receive file attachments using Paperclip. Now I need to allow a .net/C# cell phone application to post files along with the XML in the same way (or some other way if necessary: they could encode the image as base64 and send - they tried that initially - including the binary data in the tag that woul...

Custom validation help needed.

hi i have in my model: validate :check_product_stock def check_product_stock @thisproduct = product.id @productbeingchecked = Product.find_by_id(@thisproduct) @stocknumber = @productbeingchecked.stock_number if producto.en_stock == 0 raise "El Producto no tiene stock suficiente para completar la venta" #errors.add ...

Reverse order of display of blog entries and comments, Ruby on Rails

I am new to rails so could use some help here. I have followed several tutorials to create a blog with comments and even some of the AJAX bells and whistles and I am stuck on something that I hope is easy. The default display for both blogs and comments is to list the oldest first. How do I reverse that to show the most recent entries an...

Count records for Blog in Ruby on Rails - Easy Question

I am new to rails so sorry for the simple question. I have followed several tutorials and set up a blog with comments (even using a little AJAX - Ha proud of myself). I have done some customizing and right now I am trying to display in the index.html.erb a comment count that is a clickable link that takes to you the show.html.erb page. H...

changing password with authlogic - validation not catching blank inputs

I am trying to create a form to allow users to change their password: View: - form_tag change_password_users_path do = error_messages_for :user, :header_message => "Please Try Again", :message => "We had some problems updating your account" %br = label_tag :password, "New password:" = password_field_tag "password" %br =...

RoR - Removing comma

hi help me to write rails code to remove comma for the below code <% student = [] student << "About Section:" student << student_input(@input, :section_name) student << student_input(@input, :section_strength) %> <%= student.join(", ") %> I have output for this as " About Section:, section name, section strength " I just want to ...

Implementing an upload controller like Basecamp

Wondering how I could implement an upload controller like the Basecamp API, where you can upload a file attachment, receive an XML response containing an ID for that photo, then use that to reference the file in a subsequent XML post to attach the XML record to the file attachment... ...

Rails (RoR) ActiveRecord custom validation

I'm trying to extend ActiveRecord with the custom validation method validate_as_email so i could use it like this: class User < ActiveRecord::Base validates_as_email :email end I found description on how to extend ActiveRecord::Base class here: http://guides.rubyonrails.org/activerecord%5Fvalidations%5Fcallbacks.html It says you hav...

ActionMailer and Exchange

Hello Community, I successfully send Mails via SMTP using my Rails App and my Postfix Server. Now I need to move to an Exchange: Microsoft ESMTP MAIL Service, Version: 6.0.3790.3959 that has POP3 and SMTP support enabled. I use actionmailer 1.2.5 and am not able to successfully login to the server while trying to send a mail. In ca...

ROR Self referential has_many through with accept_nested_attributes_for

Hi. I wondered if someone could take a quick look at this. I'm making a simple conversion application which converts between units of measurement. I need to be able to self reference the table using a join table which stores the relationship between each, along with the conversion between each. This then would be referenced between eithe...