Hello!
What I want is to create a Model that connects with another using a has_many association in a dynamic way, without the foreign key like this:
has_many :faixas_aliquotas, :class_name => 'Fiscal::FaixaAliquota',
:conditions => ["regra_fiscal = ?", ( lambda { return self.regra_fiscal } ) ]
But I get the error:
: SE...
Hi
I am creating a simple canvas using processing.js , how to pass values from rails application to Processing.js
void drawBox(int bx, int by, int bs, int bs){
strokeWeight(3);
stroke(50,50,50);
// Test if the cursor is over the box
if (mouseX > bx-bs && mouseX < bx+bs &&
mouseY > by-bs && mouseY <...
Hi, I want to add a revision counter to my rails app.
Not the number of commits necessary but the number of live pushes/deployments for example.
I'm using github as my remote repo.
Any suggestions?
Thanks
...
I am planning a web-based commercial application with front-end RoR and back-end PostgreSQL.
I've some confusion about RoR and PostgreSQL Edition to use. For RoR, I have Aptana RADRails installed. For PostgreSQL, a free variant is also available at EnterpriseDB.
Previously I installed a free EnterpriseDB PostgreSQL variant and it was v...
Hello
I have a form in witch users can add their working hours view them and edit them (All in one page). When adding working hours the user must select a project from a dropdown list. In case the action is adding a new hour record the dropdown field should remain empty (not selected) in case the action is edit the dropdown field should ...
I have a RoR application (ruby v1.8.7; rails v2.3.5) that is caching a page in the development environment. This wouldn't be so much of an issue, but the cached page's A elements are incorrect.
I haven't made any changes to the development.rb file and I haven't knowingly added any caching commands to the controllers.
I've tried cleari...
I have a rails app that I'm going to host on engineyard and want to store image files on s3.
But I don't know if I want all developer machines to beusing s3 for storage of all our test and dev images. Maybe it's not an issue -- but it seems like a waste to have everyone storing all our images in s3.
I've heard of some ppl who store ima...
I understand the benefit of putting classes, modules, etc. in the lib folder in Rails, but I haven't been able to find a clean way of testing these files. For the most part, it seems like unit tests would be the logical approach.
I guess my question is: What is the "rails way" for testing lib files?
...
So in my Rails models I'm doing the following to generate an "SEO friendly" slug:
def to_param
"#{id}-#{title.parameterize}"
end
So that generates something like: example.com/items/1-example-title
But when I check my logs, the SQL calls are then:
SELECT * FROM `items` WHERE (`items`.`id` = '1-example-title') LIMIT 1
That seems t...
In my rails app i need to write a ruby script which the admins use to check the status of the application. i need to check the connectivity of mysql connection, like the app is connected to the DB or not.. How do i do this . this ruby script i ll place in the script directory..
Thanks in advance.
...
Let's say that I have two models - one called Post and one other called Video. I then have a third model - Comment - that is polymorphically associated to to each of these models.
I can then easily do post.comments and video.comments to find comments assosciated to records of these models. All easy so far.
But what if I want to go the ...
Hi
I want to add "Sharing documents" feature to my app, like in google documents service. As i see:
User can:
can list/view/create/edit/delete own documents
share own document to everyone - its a public document
share own document to another user with read-only access
share own document to another user with read-write access
view li...
I set up a rails project and initiated git..
then created heroku and added git remote..
But while using git push heroku master, a dialog box opens and asks to for a password to unlock the private key..
when i entered the heroku password, its not authenticating??
which password should i use to unlock the private key??
...
Hi there
I'm trying to run the following code:
<% form_for :user, :url => {:action => :welcome} do |f| %>
<table>
<tr>
<td align="right"><%= f.label :name %></td>
<td><%= f.text_field :name %></td>
But I'm getting "undefined method" when I try to run it using cucumber/webrat, while rendering the page. Running on the web brow...
How can I get rid of validation messages telling me that:
Login is too short (minimum is 3 characters)
Login should use only letters, numbers, spaces, and .-_@ please.
Password is too short (minimum is 4 characters)
Password confirmation is too short (minimum is 4 characters)
this happens even before map_openid_registration is called,...
I am using content_for and yeild to inject javascript files into the bottom of my layout but am wondering what the best practice is for including inline javascript. Specifically I'm wondering where the put the script type declaration:
<% content_for :javascript do %>
<script type="text/javascript"> ... </script>
<% end %>
or
<% ...
I have a fairly simple model; Users have_many products. I would like to be able to view a list of all products as well as a list of the products associated with a given user. My routes are set up like this:
/products
/products/:id
/users
/users/:id
/users/:id/products
The catch here is that I'd like to display the product list diffe...
I have controller with action new, and I want it to create ActiveRecord::Base descendant object, and write it into database (without showing it to user).
def new
active_order = current_user.orders.find {|o| o.status > 0 }
active_order = Order.new if active_order.nil?
(...)
end
Order.new creates local object, but my question is -...
I'm wondering what the best practice is for passing variables to JavaScript functions in a rails view. Right now I'm doing something like:
<% content_for :javascript do %>
<script type="text/javascript">
Event.observe(window, 'load', function(){
js_function(<%= @ruby_array.to_json %>, <%= @ruby_var %>); )}
</...
class User < ActiveRecord::Base
has_attached_file :photo, :styles => { :square => "100%", :large => "100%" },
:convert_options => {
:square => "-auto-orient -geometry 70X70#",
:large => "-auto-orient -geometry X300" },
:storage => :s3,
:s3_credentials => "#{RAILS_ROOT}/config/s3.yml",
:path => ":attachment...