I have a nested forms like:
class House < ActiveRecord::Base
has_many :rooms
accepts_nested_attributes_for :rooms
attr_accessible :rooms_attributes
end
class Room < ActiveRecord::Base
has_one :tv
accepts_nested_attributes_for :tv
attr_accessible :tv_attributes
end
class Tv
belongs_to :user
attr_accessible :manufactur...
I'm using /usr/bin/file -i SOME_FILE to detect whether it contains non-ascii-and-utf characters. However, it produces different result when the application is deployed to apache+passenger.
In 'script/console', above line gives:
SOME_FILE: text/plain; charset=utf-8
In passenger, it gives:
SOME_FILE: regular file
Since I am pointing ...
Hello,
I'm currently working on an authentication system derived of OpenID.
I work in Ruby and I use the ruby-openid library.
Currently, for my tests, I use fakeweb to fake an openid consumer and server and check everything works well.
But I don't like the way I do it. And I'm sure there'd be a much better way to do so.
So my question...
This may be really obvious, but in rails how can I get the contents of a page without making an HTTP request?
i.e. I want to grab the contents of any page that my rails app generates, in a script on the same server. This is of course trivial with an HTTP request, but how can I get the contents of a page otherwise?
This is what I am doi...
Hi. I am developing rest app in Rails and I have a problem. I send ajax post request to rails rest app
update_feedback : function(attrs, success, error){
$.ajax({
url: '/sync/feedback',
type: 'post',
dataType: 'json',
success: success,
error: error,
data: attrs,
fixture: f...
OK, I've been playing around with some of the eager loading things, and have 2 models something like:
Class Recipe < ActiveRecord::Base
belongs_to :cookbook
has_many :recipetags
end
and
Class Cookbook < ActiveRecord::Base
has_many :recipes, :include => [:recipetags]
end
Which is working out well, when I find a Cookboo...
Hi,
I currently have two Ruby selects: one for categories and the other one for subcategories. As you may anticipate, the second one has to update itself every time the first one changes.
For example, if I select from the first one the category "Sports", the second select should load all the sports.
How can I handle that "index change...
Can I add custom model attribute titles, so forms could automatically render them instead of "prettied" column name?
For example I apply some method in my model, which defines attribute title:
imaginary_method_which_defines_attribute_title :description, "Aprašymas"
So I do not need to write title in every form label helper:
<%= f.la...
Is there a generally accepted way of overriding error (validation) messages from a gem/plugin in rails?
For example, I'm using the ActiveMerchant gem, and if someone puts in an American Express credit card number, but selects 'MasterCard', I get a not-very-descriptive "Type is not the correct card type" error.
I can easily get around t...
I want to have a text value for a form like "search website.com..." but if the form has been submitted i want the query to appear- i dont know ruby idioms that well but i was think
<%= text_field_tag "q", params[:q] | "search website.com...." %>
is this correct?
...
I've got a database table that is shared with another application. It has many columns that I will never use in my application. Is it possible to specify columns to be ignored in the ActiveRecord model?
Usually it's not too big of a deal, but in this case I've got a table with two blobs that I'll never need joined with another table ...
I wanted to make a simple chart of users that have been created in the past month in my app. Like basically for each day in the past month I want to show the count of users that have registered that day. What I have so far:
# Controller
@users = User.count(:order => 'DATE(created_at) DESC', :group => ["DATE(created_at)"])
# View
<% @us...
My RoR server receives a string, that was encrypted in C++ application using des3 with base64 encoding
The cipher object is created so:
cipher = OpenSSL::Cipher::Cipher::new("des3")
cipher.key = key_str
cipher.iv = iv_str
key_str and iv_str: are string representations of key and initialization vector for encryption algorithm. They a...
I'm adding a test task in my Rakefile, similar to this:
namespace :test do
desc "Test lib source"
Rake::TestTask.new(:lib) do |t|
t.libs << "test"
t.pattern = 'test/lib/*/_test.rb'
t.verbose = true
end
end
and then adding (have also done using "enhance" with the same result:
task :test => [ 'test:lib' ]
My problem is...
I was using mysql just fine until I recently switched one of my rails apps to heroku and had to change over. Almost everything works as expected except I have one query which does something totally funky.
This is the postgres, but under mysql it is mostly identical except for the EXTRACT DOW and some group by additions, but that isn't ...
What do the letters RJS stand for? Is it as simple as Rails Java Script?
...
Hi
I have an issue. I have a show view that acts as a dashboard and brings in records from other models and then models associated to that. I have a simple search form that is working fine to search through one model, but I don't know how to have it look through its associated models as well. I don't think a full text search is necessary...
I'm building an app, where users can give comments by just leaving their email to the comment.
I want them to be able to register directly from there, by a link with their email adress as a param (like: <%= link_to register_path(:email => @comment.email %> ) - so there is no existing user record yet.
this should be done by applying a va...
Hello,
I am using Rinjael to encode in VB.NET and need to decode in Ruby. My VB.NET encryption class looks like this:
Private Class Encryptor
Private symmetricKey As System.Security.Cryptography.RijndaelManaged
Private iVector As Byte()
Private Key As Byte()
Public Function encrypt(ByVal data As String) ...
In one of my index actions I want to display a link that says either "activate" or "de-activate", depending on whether the record is active or not.
When the user clicks on an "activate" or "de-activate" link for a particular record, a call should be made to my update action that updates the record accordingly, and if the link said "acti...