In the following code a post is created and belongs to Person:
class Person < ActiveRecord::Base
has_many :readings
has_many :posts, :through => :readings
end
person = Person.create(:name => 'john')
post = Post.create(:name => 'a1')
person.posts << post
But I wonder which Reading this post belongs to when it's saved.
I dont qu...
Hi,
I'm currently writing a Rails 3 app that uses the google maps API (v3) extensively. Currently, the infowindow for each marker contains a link that takes the user to the page for that particular marker - ie. /places/1. A sample of my code is below:
jQuery.getJSON("/places", function(json) {
if (json.length > 0) {
for (...
This has been asked before, but didn't receive a proper answer:
I have a User that has Files. When a File is updated (via AJAX) I want to refresh the User view.
I do this in RJS:
page['user'].replace_html :partial => 'users/user'
However, the _user.erb.html partial references other partials in the users directory, and e.g. for _name...
I'm trying to find some api docs like
http://api.rubyonrails.com
but for the latest rails 3 release candidate.
Is there an online version of them? Or is there a way to build the docs (using rake doc:rails) to make them look the same?
...
Hi Everyone,
I have made a fairly simple app, which can be found on GitHub called BaseApp2.
It's basically a starter application for future apps that I make to save me redoing the same parts over and over again. It's not advanced, but it serves its purpose for me.
At the moment any information that's entered into the database is eith...
Apart from the obvious references to facebooker and rfacebook. Mainly for sign-ons and getting basic profile info
...
When I save an apartment record in rails, for some reason it is updating the updated_on field and the created_on field. I can't figure out how/why the created_on field is being updated.
To try and debug the situation, I opened up a console window and did the following
t = Apartment.find(11619)
t.beds = 4
t.save
When I check my log fi...
Hi,
I am building a social networking site in rails and I want to have a very simple messaging system. More or less just: inbox and set messages. Lastly, I'd ideally like for it to function like facebook; in the users profile you click "send message to username" and it takes you to a compose screen.
The only rails messaging system I'v...
For some reason, one of my models in rails is returning nil when I call .new. This is only a problem in the controller. When I try on the console, it returns an object with nil attributes as I would expect. I suspect the problem is in my controller, but I have no idea.
This also happens when I call .all. Again, I can execute these comm...
Say you have a Post model that has a :title, :author, :content, etc. It also has a :thread_id attribute, and it belongs_to :thread.
The thread model doesn't have any custom fields. The only ones you'll be needing are those created by default such as :id, :created_at, and :updated_at. Threads have_many :posts.
How do you create a form f...
I have no problem with adding the foreign key constraint with this gem:
http://github.com/matthuhiggins/foreigner
However, I cannot remove the foreign key.
class ForeignKeys < ActiveRecord::Migration
def self.up
add_foreign_key(:threads, :users)
end
def self.down
remove_foreign_key(:threads, :column => :user_id)
end
e...
I see the following error when I start my rails app:
$ script/server --environment=production
=> Booting WEBrick
=> Rails 2.3.5 application starting on http://0.0.0.0:3000
/usr/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails/gem_dependency.rb:119:Warning: Gem::Dependency#version_requirements is deprecated and will be removed on or af...
Say I have a table animals that has a column parent_id
Say also that I have a type_id on the table to indicate species
So in my Animal class, Animall.all would return all animals.
Say that now I add two new animal types, dog and cat in the animal_types table. So now some animals have type_id of 1 and some 2.
I could write a named_sco...
I read a few tutorials on getting memcached set up with Rails (2.3.5), and I'm a bit lost.
Here's what I need to cache:
I have user-specific settings that are stored in the db. The settings are queried in the ApplicationController meaning that a query is running per-request.
I understand that Rails has built-in support for SQL cachei...
I'm just starting out in Ruby (Rails actually) and the book I'm reading covers Ruby 1.8.6, RubyGems 1.0.1, Rails 2.0.2 and SQLite 3.5.4, but the current stable releases of these are 1.9.1, 2.3.8, 1.3.7 and 3.7.0 respectively, should I still proceed with the book or find another?
Also, I couldn't find a recent guide/tutorial to walk me t...
Simplified version of my problem:
I have some variable, that contains some xml.
x = "foo
I'd like to generate XML that looks like this:
x <-- contents of x
So I have an xml builder partial that looks like
xml.map do
xml.other_stuff do
end
end
how do I insert x in there?
If the question isn't clear just yell at me and I'll r...
I'm looking for good ruby/rails oriented twitter accounts to follow. Interesting in news/events in life of ruby/rails community.
...
MBPro:shovell myname$ ruby script/server
=> Booting WEBrick
=> Rails 2.3.8 application starting on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2010-08-01 15:28:35] INFO WEBrick 1.3.1
[2010-08-01 15:28:35] INFO ruby 1.9.1 (2010-07-02) [i386-darwin10.4.0]
[2010-08-01 15:28:35] INFO WEBrick::HTTPServer#sta...
Hello everyone. I am building a complex HTML 5 application that takes advantage of Websockets. I am getting to the point where I have a lot of different types of data that gets updated in real time on the screen.
I want to know if it is going to be better for me to have fewer Websockets that are more complex, or a lot of simple Websock...
As you can see at https://ssl.virtualweb.at/redmine/ i try to get Redmine up & running.
At the start i got this error:
undefined method `mattr_accessor' for ActiveSupport::Deprecation:Module
Could someone be so nice an give some tipps how to get it to run?
t.i.a.
...