Are there any good examples/plugins that enable users to create groups within a community application. For example, I would like to create a Group class and add it to something like Community Engine (http://communityengine.org/). Essentially, users need to be able to create and manage groups that other users can join (much like Facebook ...
I have a model with single-table inheritance on the type column:
class Pet < ActiveRecord::Base
TYPES = [Dog, Cat, Hamster]
validates_presence_of :name
end
I want to offer a <select> dropdown on the new and edit pages:
<% form_for @model do |f| %>
<%= f.label :name %>
<%= f.text_input :name %>
<%= f.label :type %>
<%= f....
I'm using mongo_mapper 0.7.5 and rails 2.3.8, and I have an instance method that works in my console, but not in the controller of my actual app. I have no idea why this is.
#controller
if @friendship.save
user1.add_friend(user2)
...
#model
...
key :friends_count, Integer, :default => 0
key :followers_count, Integer, :default => 0
...
I'm using ruby on rails 2.3.8 and will_paginate plugin.
I've just noticed that if I write something like this:
Announcement.paginate :page => params[:page], :per_page => 10, :conditions => some_condition
it will work.
But, if I write something like this:
announcements = Announcement.all :conditions => some_condition
@ann = announce...
The core of this question is where build_attribute is required in a model with nested attribuites
I'm working with a few models that are setup like:
class Person < ActiveRecord::Base
has_one :contact
accepts_nested_attributes_for :contact, :allow_destroy=> true
end
class Contact < ActiveRecord::Base
belongs_to :person
has_on...
Hi,
I have a small question regarding rails. I have a search controller which searches for a name in database, if found shows the details about it or else I am redirecting to the new name page. Is there anyway after redirection that the name searched for to automatically appear in the new form page?
Thanks in advance.
...
Hi there! I am a Rails noob and have a question. I have a feed aggregator that is organized by this general concept:
Feed Category (books, electronics, etc)
Feed Site Section (home page, books page, etc)
Feed (the feed itself)
Feed Entry
So:
class Category < ActiveRecord::Base
has_many :feeds
has_many :feed_entries, :through => :...
I am an ASP.NET developer, but want to learn other frameworks/language (open source).
Django and Rails both seem promising, but I am confused which one I should choose to start, or whether I should choose some other framework.
I know learning the language (python or ruby) is a must before starting with Django or Rails.
...
Given the following models:
class Recipe < ActiveRecord::Base
has_many :recipe_ingredients
has_many :ingredients, :through => :recipe_ingredients
end
class RecipeIngredient < ActiveRecord::Base
belongs_to :recipe
belongs_to :ingredient
end
class Ingredient < ActiveRecord::Base
end
How can I perform the following SQL query us...
For one specific client I have to use PHP. This and this question were 2 years old. I'd like to know is there any update of opinion for year 2010?
My background on web development is mainly rails. I can code in PHP (for example, write a module for Drupal) but never used any PHP framework for any project.
I can see the following potenti...
I've got a named scope for one of my models that works fine. The code is:
named_scope :inbox_threads, lambda { |user|
{
:include => [:deletion_flags, :recipiences],
:conditions => ["recipiences.user_id = ? AND deletion_flags.user_id IS NULL", user.id],
:group => "msg_threads.id"
}}
This works fine on my local copy of the app wit...
Hi. As a newb, I decided to build a "home inventory" application. I am now stuck on how to programmatically select a layout based on what type of item it is when viewing it in a browser.
According to my planning, so far I should have created a few models to represent types of items I can find in my home: Furniture, Electronics and Book...
I tried to assign a class static variable like this
class QueryLogger < Logger
@@query_logger_default_instance = nil
def self.default_instance
# Use global variable because static variable doesn't work
@@query_logger_default_instance ||= self.new(STDOUT)
end
end
In initializers folder of my rails app, I added a file with...
I'm starting to get overwhelmed using VI to search through my logs to chase down login errors and would like a better solution. I know Newrelic is highly recommended, though was wondering if there was something free I could try for the short term.
Thanks!
...
I can't seem to find this and I feel like it should be easy. In Ruby on Rails, how do I take:
2010-06-14 19:01:00 UTC
and turn it into
June 14th, 2010
Can I not just use a helper in the view?
...
I want to generate the scaffold in a Rails app, generating the model as usual but having the controller inside the admin namespace. Is it possible?
...
Hi,
I entered some products data into a table using a migration. I need to expire the page and fragment cache when I update, add, delete products from this table. I created a sweeper for this.
class ProductSweeper < ActionController::Caching::Sweeper
observe Product
def after_create
expire_cache
end
def after_save
ex...
Hi All
is there any RoR method which can work same as preg_match_all() php function?
...
I thought it could be created in a few steps but it can't yet:
rails poly
cd poly
ruby script/generate scaffold animal name:string obj_type:string obj_id:integer
rake:migrate
ruby script/generate scaffold human name:string passportNumber:string
rake:migrate
ruby script/generate scaffold dog name:string registrationNumber:string
rake:...
I have a production instance in engineyard up and running well. I would like to create a new staging instance for internal testing. I cloned the existing production instance, changed Framework Environment to staging. I can deploy all the code to staging instance from Github. Engineyard reported the server is fully configured and ready.
...