I want to display a list of items in a page in Ruby-on-Rails. I use partials
in my index.html.erb file I have:
<%= @lista = News.find(:all, :order => Document::COL_DATE + ' DESC, id DESC')
render :partial => "newsitem",
:layout => "list_news",
:spacer_template => "spacer",
:collection => @lista
%>
...
I was able to successfully do a cap deploy:setup and cold
Now I went back to send a change to the server. I got all of my files into github fine, my cap deploy went fine, it compled without error, however I get the following screen (passenger error message):
Further information about the error may have been written to the application's...
I am trying to maintain a pretty URL when having a user register with failed validation
I have a routes file that looks like the following:
map.resources :users
map.signup '/signup', :controller => "users", :action => "new"
This works well enough, except that if a user enters invalid information during registration then the create me...
My rails app kicks off a process with rufus-scheduler in an initializer. Here's a stripped-down version of the initializer's code:
# config.logger isn't available here, so we have to grab it from the Rails object
logger = RAILS_DEFAULT_LOGGER
logger.warn(Time.now.to_s + ": Starting Rufus Scheduler")
# run every Wednesday at 10 AM
cro...
Hi,
I'd like to be able to describe different types of a model using RoR associations. An example:
Models:
Post
ImagePost
post_id:integer
url:string
MessagePost
post_id:integer
message:string
ImagePost and MessagePost are a type of Post. I'd like @posts = Post.all to retrieve both types of post and allow me access to their attri...
I keep getting: NoMethodError in StudentsController
undefined method `id_num=' for #<Array:0x105adcc98>
I'm positive there's an id_num in table and it's occuring in the controller:
Students Controller:
def student_test
@student = Student.find(params[:id]) if params[:id]
@student ||= Student.new
run_sequence :testize
end
def test_fi...
I have a serialized field called options(of type Hash) in my User model. The options field behaves like a Hash most of the time. When I convert the user object to XML, the 'options' field is serialized as a YAML type instead of Hash.
I am sending the result to a Flash client via REST. This behaviour is causing problems at the client si...
Our team is developing a Rails app on MySQL and using config.active_record.schema_format = :sql per The Rails Guides.
Naturally, our AUTO_INCREMENT values in development_structure.sql get out-of-sync as we develop in parallel. We know that having different values in our databases for AUTO_INCREMENT is not a technical problem. However, i...
Most of my work in a rails application is done with rails engines. When I develop new applications, it usually use a custom built cms. My CMS was inspired by refineryCMS in that there is a core that lives as a rails engine. Features that make up the application are other rails engines that register themselves with the core. For example t...
I am trying to set up a Many-to-Many association between 2 objects. I have gone through several tutorials and have been able to correctly set up the model. My problem is that I am having having trouble setting up the correct routes so I can view the full relationship... something like only displaying the products from a specific catego...
I'm trying to access:
http://localhost:3000/images/Header.png
but I keep getting this error:
Routing Error
No route matches "/images/Header.png" with {:method=>:get}
And here are my routes:
ActionController::Routing::Routes.draw do |map|
map.resources :worker_antpile_statuses
map.resources :worker_antpiles
map.resources ...
I'm trying to install the rails 3.0.0.beta and I'm running into this issue:
justins-mac-: justinz$ ruby -v
ruby 1.8.7 (2008-08-11 patchlevel 72) [universal-darwin10.0]
justins-mac-justinz$ rails -help
/Library/Ruby/Site/1.8/rubygems.rb:384:in `bin_path': can't find executable rails for rails-3.0.0.beta (Gem::Exception)
from /usr/bin/ra...
Hello, I am trying to update InstantRails, and I did really, really google for any tutorial for it but found none. One site was mentioned to have contained a tutorial but it is not gone http://dwiardiirawan.com/. I know there's this installer available for Windows, but I think one needs to extract a tar file and replace the existing file...
Two apologies in advance. One for trying to fight rails defaults, another for the example in the title, which I think sums up my question better than I can otherwise. Any way to do what I want without having the world collapse on itself? I got as far as putting a to_param in my model, but that doesn't quite go all the way.
...
This is a tad different from rememebering say sort-by-date or sort-by-alphabet. I have a list of Items, that I'd like to allow the User to rearrange. More importantly, I'd like to remember that order. How would I do this?
...
I would like to define a method where the first argument is required and the rest are optional. Only first argument must be at first pace.
I try to do this:
my_method(:id, :tags, :user)
my_method(:id, :user, :tags)
def(id, *args)
... id...
... args[:tags]...
... args[:user]...
end
Thank you!
...
What I Want
I want to read the cache of Safari through Active Record. Essentially, I want to peek inside the cache like this except from within a Rails app.
What I've Tried
I copied the Cache.db file
I set up the environment.rb file in a new Rails app with the path of a copy of the Safari Cache.db SQLite Database.
Ran db:migrate
Thi...
I have two models, links and tags, associated through a third, link_tags. The following code is in my Link model.
Associations:
class Link < ActiveRecord::Base
has_many :tags, :through => :link_tags
has_many :link_tags
accepts_nested_attributes_for :tags, :allow_destroy => :false,
:reject_if => proc { |attrs| attrs.all? { |k...
Now that Rails 3 beta is out, I thought I'd have a look at rewriting an app I have just started work on in Rails 3 beta, both to get a feel for it and get a bit of a head-start. The app uses MongoDB and MongoMapper for all of its models nad therefore has no need for ActiveRecord. In the previous version, I am unloading activerecord in th...
Hi,
This certain part of my application takes cares of creation of Webshop model for store chains (like H&M) that has one. If the chain has a website that also is a webshop it creates one Webshop model.
If the website is not a webshop then it lets it be just at string in the Chain model.
PROBLEM: I'm doing this with a checkbox and vir...