I seem to be getting error:
uninitialized constant Style::Pic
when I'm trying to render a nested object in to the index view the show view is fine.
class Style < ActiveRecord::Base
#belongs_to :users
has_many :style_images, :dependent => :destroy
accepts_nested_attributes_for :style_images,
:reject_if => proc { |a| a.all? { |k, v| ...
This is probably a really dumb question with a simple answer but...
I am working on a project where I need to use AJAX to send/receive information. I am using Ruby on Rails (which I am pretty new to), but rather than using the helper methods or the built in functionality in the 'defaults' Javascript file, I need to do this manually in m...
I can use the following to group results, but it only returns one result per group.
@results = Model.search params[:search_query],
:group_by => 'created_at',
:group_function => :day,
:page => params[:page],
:per_page =>...
Hey,
I'm looking for a way to get the content of my div in my Rails view. I would like the literal HTML content, so only HTML and no Rails
I thought inner_html would work, but I get a RJS exception (TypeError: $("content").innerHtml is not a function)
Does anyone know how I can get the content?
Thanks!
In my controller I use this c...
They don't seem to be accessible from ActionView::TestCase
...
How would I show one of many nested objects in the index view
class Album < ActiveRecord::Base
has_many: photos
accepts_nested_attributes_for :photos,
:reject_if => proc { |a| a.all? { |k, v| v.blank?} }
has_one: cover
accepts_nested_attributes_for :cover
end
class Album Controller < ApplicationController
layout "mini"
def i...
I thought every time you do a flash[:notice]="Message" it would add it to the array which would then get displayed during the view but the following just keeps the last flash:
flash[:notice] = "Message 1"
flash[:notice] = "Message 2"
Now I realize it's just a simple hash with a key (I think :)) but is there a better way to do multiple...
I'm a beginning programmer in the relevant areas to this question, so if possible, it'd be helpful to avoid assuming I know a lot already.
I'm trying to import the OpenLibrary dataset into a local Postgres database. After it's imported, I plan to use it as a starting seed for a Ruby on Rails application that will include information on ...
Hey guys,
I'm adding reporting functionality to a project.
3 roles here:
1) Volunteers (they report what hours they volunteered)
2) Supervisors (they look at the reported stuff, note: one supervisor can view all projects)
3) Projects (Represents a work project that some collection of volunteers work on)
To explain what it does:
A ...
When using :methods in to_json, is there a way to rename the key? I'm trying to replace the real id with a base62 version of it and I want that the value of base62_id has the key id.
@obj.to_json(
:except => :id
:methods => :base62_id
)
I tried to do
@obj.to_json(
:except => :id
:methods => { :id => :base62_id }
)
b...
I have a YML file containing fixtures for a Rails model (Comment) which looks like this (pardon the formatting):
comment_a:
id: 1
text: 'foo'
visible: false
comment_b:
id: 2
text: 'bar'
visible: true
comment_c:
id: 3
text: 'baz'
visible: true
I know that I can select an individual Comment fixtur...
Say I have a Metal class named Preview. How do I test it with RSpec?
When I try:
require 'spec_helper'
describe Preview do
it "should return the posted content" do
post "/preview", :content => "*title*"
response.body.should == "*title*"
end
end
I get:
undefined method `post' for #<ActiveSupport::TestCase::Subclass_1:0...
Using ruby-debug, when I issue a list command, it shows old code. So if I update the code surrounding (especially before) the debugger command in the model it still shows the old code.
The only way I have found to 'refresh' this code is by stopping the server and running it again.
Is there a better way?
Thanks,
Josh
...
I am trying to hash or encrypt a record's ID for URLs such that people can't view various records simply by guessing different integer IDs.
Essentially, my URLs would be something like this: /plans/0AUTxwoGkOYfiZGd2
instead of /plans/304.
Would the best way to do this just be to use SHA-1 to hash the plan's id and store it in a hashed_...
This is a simple way to do Rails-style migrations in a VBA application. Just add additional migrations like migration(name, sql_string, database) to run_migratons and call run_migrations somewhere in the beginning of your execution.
Function migrate(signature As String, sql As String, dbs As DAO.database)
Dim rs As DAO.Recordset
...
Im trying make a login page for my rails application that looks like "www.domain.com" and when you login you still are still located at the domain "www.domain.com". Is there a way that I can map 2 different actions to the same url using routes. Twitter does it this way, you log in at twitter.com and after you are logged in you are still ...
This seems to have been asked before: http://stackoverflow.com/questions/1402547/rails-decimal-precision-and-scale
But when running a change_column migration for :precision or :scale they don't actually affect the schema or database, but db:migrate runs without errors.
My migration file looks like this:
class ChangePrecisionAndScaleO...
Hello,
I have a paperclip attachment in one model, but I`m not saving the file in /public, but /assets. And when the user what to open the file I use the send_data() function, which makes the user to download the file.
My question is how can I show the file in other way (not nessecery to download)? So if the file is a image, I will see ...
If i define a few gems in my config/environments/test.rb file like this:
config.gem "rspec"
config.gem "rspec-rails"
config.gem "mocha"
and then run 'rake gems:install RAILS_ENV=test'
I get the following error:
Missing these required gems:
mocha
Run rake gems:install to install the missing gems.
however if I run rake gems:inst...
I have an entry.rb model and I'm trying to make a semi-complicated validation. I want it to require one or more of the following fields: phone, phone2, mobile, fax, email or website. How would you write the intended code? Would something like this work?
validates_presence_of :phone and or :phone2 and or :mobile and or :fax and or :email...