How would you map the dashed association using ActiveRecord? Is there any ActiveRecord-way of doing it? What I want is to get all unique available promotions for a particular item.
Here are things I thought but I don't really like:
Using custom finder
class Item < ActiveRecord::Base
has_many :promotions, :finder_sql => "SELECT..FR...
I am working on the application that require documents to be embeded inside the webpage .
I want to embed a powerpoint slides inside the page, any pointer would be helping
The application i am working on is built on Ruby on Rails
I have checked google doc viewer but for some reason its not rendering the pdf/ppt from my application
c...
In a Rails view, I'm trying to show a <select> drop-down list for a number of different string fields with restricted values.
I've been trying to do this with a partial (below), but the current value is not being selected in the <select> list.
Is it possible to do this in a partial? If so, how?
Is there a better approach to take?
...
Hi, I am looking for a payment processing solution for my Rails e-commerce site, here are my requirements.
Simple Rails integration, e.g through
activemerchant plugin.
Operates in the UK.
Payments can be taken on my site (not redirected to third party)
Preferably no/low monthly cost, and therefore higher transaction percentage for when...
I'm building an article/blog website where any article may show up within a series of URL paths.
/section/article
/section/page/article
/section/page/page2/article
This works, but what if I wanted to have the page number for that article (/page/123) be bound to those URLs
/section/article/page/123/
/section/page/article/page/123
/sec...
Hello frens..
I am having problem updating the embedded documents in mongodb.
I have a following scenario.
A User model has address as the embedded docs.
I am able to embed the address to the parent model ie; User model but i still cant figure out how to update the address embedded even though i have the _id of the address embedded
Plea...
Is a web framework, such as Django and Ruby on Rails, simply a way of displaying code that could be written normally over http? Or is it used for more server side things, such as storing data. Is it used as a front-end or back-end for websites?
...
What is the best Ruby library for dealing with Excel spreadsheets?
I found spreadsheet-gem but I didn't find it to be as good as PHPExcel - a library I used to use when I was a PHP developer.
Please help.
Thanks.
...
I've begun using Formtastic in the last couple days and have come to my first head-scratcher.
I'm working with items that each have a few associated accounts. On the page in question you need to select a payee account. It can either be an account we already know about (the "Main Contact") or a new account that you can create by fillin...
I have a Phone model for phone numbers in my application thats built as follows:
t.column :number, :string
t.references :phoneable, :polymorphic => true
I want to restrict the number to be of the format 317.555.5555x234, so I'm creating a form with four boxes (area code, 3 digits, 4 digits, ext):
- form_for @user do |user_fo...
Goal: Using a CRON task (or other schedule event) update rails database with nightly export of data from an existing system.
All data is created/updated/deleted in an existing system. The website does no directly integrate with this system, so the rails app simply needs to reflect the updates that appear in the data export.
I have a .t...
Hi all.
I'm a happy user of RoR but have one complaint. When I do script/generate scaffold it automatically generates all my files and places them in their proper folders. However, all the different scaffolds I've created name their view files the same.
I have a bunch of index.html.erb view files and when I have them open in my tex...
I have a form for an instance of a "project". Each project can have many clients. Each client is a unique pair of organization and individual (contact person).
So, Project has a many-to-many relationship with Client. Client has a many-to-one relationship with organization and a many-to-one relationship with Organization.
See an image ...
I'm working with CKeditor, and for whatever reason, they included Hspace and Vspace in their UI. Convenient idea to allow users to manipulate their images like so, but those are way deprecated.
Has anyone converted CKeditor's Hspace and Vspace to CSS, and know how to explain its conversion?
I am a javascript novice..
...
I have an array of 'questions' ordered according to their number of votes, and want to show the question immediately before and immediately following the currently-selected question.
Let's say the currently-selected question is stored in the variable @question, and I'm showing a list of other questions associated with the same user. Thi...
In a Ruby on Rails app I'm working on I have a Model that belongs_to a User. The User can create many of these.
When a user goes to the new action, I want to prepopulate the values with the values from the last record they created. These can then be changed if desired and used to create a new record.
I'm assuming that in the new a...
I'm looking to capture just the number after vspace. How would you do that in regex? Here is a sample string.
<img align="left" alt="dude its me" border="10" height="168" hspace="30" vspace="10" width="130" />
So the end result would be 10
...
Hi, I've been away from Rails for a while now, so maybe I'm missing something simple.
How can you accomplish this:
<%= yield_or :sidebar do %>
some default content
<% end %>
Or even:
<%= yield_or_render :sidebar, 'path/to/default/sidebar' %>
In the first case, I'm trying:
def yield_or(content, &block)
content_for?(content) ? ...
I have a straightforward relation between two models: Asset and Update.
both models (minus unrelated methods) here:
http://pastie.org/1062627
I ran into a problem where an Asset record will no longer update. For example a simple test:
a = Asset.first ; puts a.description; a.description = "new" ; a.save ; puts a.errors ; puts Asset.f...
I have
add_column :foos, :bar_id, :integer
but I wast to be able to do stuff like
@foo.bar.name
rather than
Bar.find(@foo.bar_id)
I think its done with t.references when creating a table... but how do a add it post-table-creating?
...