I have two quite nasty problems with join model. I think I am just going wrong
way, so maybe someone can clear up my approch a bit. First there are some models
with realtions like this:
class Account < ActiveRecord::Base
has_many :tickets, :through => :assigment
has_many :assigments
...
end
accepts_nested_attributes_for :assigmen...
I've got the following select() form helper method:
select("treatment", "frequency_unit", { "hour" => "hour", "day" => "day", "week" => "week", "month" => "month", "year" => "year" })
The helper is organizing the choices seemingly randomly...I'd like it to maintain the order of the choices as I have them listed above.
How can I make ...
Hello there, I'm trying to override the way rails apply and id to an associated object, for example:
There are 2 simple models:
class Album < ActiveRecord::Base
has_many :photos
end
class Photo < ActiveRecord::Base
belongs_to :album
end
And then I want to do this:
album = Album.new :title => 'First Album'
album.photos.build
alb...
I am doing some plain SQLs in my rails model (for purists this is just for complex SQLs :)
Since I am not using find*/condition methods, is there a helper method that I can use straight to do that?
...
i wonder if you can route a request to a specific controller with query string.
eg. if a request contains a querystring "q=hello" then it would be sent to a specific controller.
and if it contains "search=hello" then it would be sent to another controller.
is this possible?
thanks!
...
I want to create user-specific validations.
User has a column called "rule_values" which is a serialized hash of certain quantities.
In a separate model, Foo, I have a validation:
class Foo < ActiveRecord::Base
belongs_to :user
n = self.user.rule_values[:max_awesome_rating] #this line is giving me trouble!
validates_presence_o...
Hello, whenever I run the bundle install command, bundler creates a directory in my projects root with the name '?'. How can I prevent this from happening?
I'm assuming the ? directory is due to the fact that some path has not been found, but which? And how could I tackle this issue?
Best regards,
DBA
...
I'm trying to get my head around this one:
Say you have two models where:
:bar has_many :foos
And you have a url like this: http://myapp.com/24-name-of-the-bar-to-param/foos/new
On my site this page shows a lot of information about the bar which users are going to create a foo for. So, even if a user isn't logged in the user will sti...
How do I search for a string in Ruby on Rails?
For example, all records with columns that contains "text".
Does Active Record have a method for it or do I have to use SQL "LIKE" for it?
...
i have added one route and one link and the load time for the page is now 5-6 seconds more.
here is the routing:
root :to => 'firstpage#index'
resources :menus
# this one is added
match 'search' => 'search#index'
here is the link in the view:
<%= link_to "Sök", :controller => "search", :query => "ruby on rails" %>
i gues...
I'm writing a Ruby on Rails app that normally runs on Heroku or a Linux Box, but I'd need to deploy it to a Windows Server as well.
The Server is a 64-Bit Win2008 Server with IIS 7.0 installed, so normally I'd prefer using IIS instead of setting up an Apache next to it.
I just don't know if Ruby/Rails works with IIS? Do Gems work? Is 6...
I have an application which has the requirement, but infrequent usage, of uploading an image for use in other parts of the application. It's not something that is done frequently, nor is it frequently viewed (such as a photo). It is an image which is then sent through an API to print and deliver as a postcard.
Initially I used papercl...
I've overrode the method find for ActiveRecord::Base and that went pretty well, now I can customize it nicely.
def self.find(*args)
# my custom actions
super(*args)
end
then
Album.find(1) #=> My custom result
But now I would like to override this:
Album.first.photos
and I'm not sure what method exactly I should override to ...
Right now my Usermailer is written so I have UserMailer.delay.deliver_blah. Everything works perfect, but like before I'd like the contents of the email printed out in the console for debugging. HOw do I do this?
...
My question is how do you find the "type" for a database column whats the difference between text / string. Is there anyway I can find this out?
script/generate scaffold ModelName field1:type field2:type field3:type
or
script/generate scaffold Post title:string body:text category_id:integer
...
Thanks in advanced.
So my overall goal is get a modal dialog box with a form in it to pop up. I am running into an issue when I click my link to bring up the modal it doesn't seem to be using javascript ... it just renders the page as if javascript is disabled. Code below :)
application.js
jQuery(function(){
$("#create_reminder_dial...
In Rails 3 edge, I have set up two nested resources like this:
config/routes.rb
resources :agencies do
resources :properties
end
I use Mongomapper as my ORM, and when I try to create a new property under an existing agency, I get this error:
---> http://localhost:3000/agencies/4c3ff0f455899f0fb5000001/properties/new
NoMethodErro...
This might be impossible to answer since there are probably too many variables here, but I thought I'd give it a shot since I always find other answers here. I am still fairly new to rails.
So, I have a bills model/controller/view. I want to create a new bill. I will be editing out the things that shouldn't matter much, but if they are ...
I keep getting this error:
uninitialized constant GetxmlController::Xmlparse
my code for the class looks like
require "rexml/document"
include REXML
Class Xmlparse
def parsetime
xmlfile = File.new("colors.xml")
xmldoc = Document.new(xmlfile)
root = xmldoc.root
return root
end
end
my controller looks like:
class GetxmlControlle...
I develop a simple overlay to preview image in full size.
I use "cache: false" to prevent caching.
The code is simple:
$.ajax({
url: urlFull,
cache: false,
success: function(html){
// display image
},
error: function(XMLHttpRequest, textStatus, errorThrown ) {
// display error
}
});
The problem is - Whe...