Posts has_many Comments
I'm using searchlogic which will order by named scopes. So, I'd like a named scope that orders by each post's most recent comment.
named_scope :ascend_by_comment, :order => ...comments.created_at??...
I'm not sure how to do a :joins and get only the most recent comment and sort by its created_at field, all in...
I have some saved text in my create controller. If it's not stressful, I'd like it to populate a textarea on the page with the saved text along with displaying the error message fields (which is what's already happening). I've used things like replace_html before, but I don't know if there's an easy way to get to textarea or text field I...
This is pretty simple, I just can't quite get it. I'm sure there's a rails-way to do it.
When creating a new comment, I want the user to be able to enter her name in a field, but have the form submit the matching ID for her name (or toss an error/create new person).
Thanks!
...
I've got a rails model using Paperclip that looks like this:
has_attached_file :image, :styles => { :normal => ['857x392#', :png] },
:url => '/assets/pages/:id/:basename.:extension',
:path => ':rails_root/public/assets/pages/:id/:basename.:extension'
validates_attachment_size :image, :less_th...
I have a setting in environment/production.rb of HEROKU = true
This should change my has_attachment has to use s3 instead of the file system, but it doesn't. What's wrong with my logic?
has_attachment :content_type => :image,
:storage => ($HEROKU ? :s3 : :file_system),
...
Thanks!
...
I would like to let my users create Ruby scripts that do computation on some data residing on the web server and then outputs results. The scripts are executed on the server. Is there any way to do this securely?
More specifically, I would like to:
restrict the resources the script can use (memory and cpu), and limit its running time
...
My goal is to print a json document with the structure described in the chosen answer on this thread. I only have one level of sub categories (2 total, including root) so it should be a little bit easier than the problem there. The problem I'm having is with efficiency. With only ~20 root categories the recursion is causing my script to ...
Hi,
I'm trying to get the hang of basic Rails routing.
I have a model called page which I generated with a scaffold.
I have added a method called addchild which I would like to access through
'pages/addchild/:id'
So far so good. However, I want to set up a link to this method like so:
<%= link_to 'Add child page', addchild_page_path...
Update: Working as designed once I cleared my cookies. Doh!
I'm working on an app that for various reasons uses the Facebook
Javascript API to initiate a Facebook connect session. I'd like to be
able to use that session in a few rails methods using Facebooker.
The basic workflow is like this:
User goes to non-rails page and logs in t...
I'm still super new with Rails, and just trying to get my first has_many through association set up.
Recipes have many ingredients, and each ingredient has an amount needed for the recipe. The ingredient_amount table has a recipe_id, an ingredient_id, and an amount.
When creating a new recipe, I want to be able to create these recipe/...
I installed the Acts as taggable on plugin to my 'Post' model, however I'm unable to call up a list of posts tagged with certain tag.
Here's what I have in show.
<%= link_to tag.name, posts_path(:view =>'tag', :tag => tag.name) %><% end %>
Except when I click on it, it shows all posts. I want it to show just the posts tagged with tha...
In my Ruby on Rails application I want to allow the adding/editing of a nested model which itself has an associated model.
model Survey
string title
has_many questions
model Question
string question
belongs_to category
model Category
string name
For the sake of argument let's assume that the user should always have to...
I want to use page_cache with will_paginate.
There are good information on this page below.
http://railsenvy.com/2007/2/28/rails-caching-tutorial#pagination
http://railslab.newrelic.com/2009/02/05/episode-5-advanced-page-caching
I wrote routes.rb looks like:
map.connect '/products/page/:page', :controller => 'products', :action => 'i...
I have an ecommerce store that I am building. I am using Rails/ActiveRecord, but that really isn't necessary to answer this question (however, if you are familiar with those things, please feel free to answer in terms of Rails/AR).
One of the store's requirements is that it needs to represent two types of products:
Simple products - t...
I have a model called "Post" which is a nested resource under a model called "Project" and I'm trying to test the controller. The code works find in my browser, but I can't get it to work in the test. Here's the test
context "on POST to :edit" do
setup do
post( :edit,
:project_id => @project1.to_param,
:id => @post1...
Vps hosting provides choice of operating system:
Cent OS 5
Debian 4.0
Fedora 10
Gentoo
Opensuse 10
Ubuntu 8.10
Ubuntu 8.04
Ubuntu 9.04
Which pros and cons for running rails app, software installing, overall feel, etc. do they have, or maybe there are others which are much better to serve rails
...
I'm having a little trouble understanding how the files inside the intializers folder is used. Are all the files within this directory loaded automatically? Or do we need to specify which ones in some location?
The above question came into play because I wanted to setup action mailer. I created a file called smtp_gmail.rb inside this fo...
Does anyone know how to assert that a checkbox or input is disabled? I can't find anything to indicated that this is supported
I'm writing cucumber tests with webrat and test/unit.
I'd like to have a step that is able to assert_disabled :some_checkbox || assert_disabled :some_input.
Or some way that I can check a property of the che...
In my Rails app, I have a model called "Photo" and a PhotosController. As would be expected, I've RESTfully routed the URLs so that the URL "/photos" returns an HTML-rendered list of all photos (as thumbnails), and "/photos/foo" returns an HTML-rendered representation of the photo with the friendly_id of "foo". (I also do XML, JSON, and ...
We’ll be releasing shortly a companion Rails application to our existing Rails app. We will be running the companion app alongside our existing app on the same servers.
My question concerns the databases. My hosting provider generally would configure a 2nd distinct database for the new application - secondappname_production. However,...