ars next to "Massaged city".
So, strange as it sounds, the variables seem to be differently bound
depending on which line is being evaluated. So far I've not been able
to puzzle through the sequence of events in such a way as to come up
with a way to inject the state and city values into
.rb:206:in
That's where inject is being called.
/Users/mitch/railsprojects/gould_development/app/controllers/public_controller.rb:7:in
`home'
What does that method look like?
David
--
David A. Black, Senior Developer, Cyrus Innovation Inc.
The Ruby training w
cases where having the flat scope would be so
important as to lead me to use for if I didn't have some other reason to
(which I don't think I ever have).
David
--
David A. Black, Senior Developer, Cyrus Innovation Inc.
The Ruby training with Black/Brown/McAnally
Co
ber 9), $650 regular. There's
a 10% discount for groups of 5 or more signing up together.
More info and registration links at http://www.compleatrubyist.com --
please let us know if you have any questions.
See you in Philly!
David
--
David A. Black, Senior Developer, Cyrus Innovation I
On Sun, 11 Jul 2010, RubyonRails_newbie wrote:
On 11 July, 21:23, "David A. Black" wrote:
On Sun, 11 Jul 2010, RubyonRails_newbie wrote:
i'm trying to add comments to a blog.
I got it working, but i want to store the user too, so I added the
user_id to the blogcomments ta
er id, but not the body, blogpost id)
def comment
@blogcomment = Blogcomment.find(:all, :order => "created_at
desc")
@user = User.find(session[:user_id])
@blogcomment = Blogcomment.create(:id => > params[:body],
Do you mean :body there, rather than :id?
n the string "answer".
That's true in Ruby 1.9, but in < 1.9 it will return something
else
David
--
David A. Black, Senior Developer, Cyrus Innovation Inc.
THE Ruby training with Black/Brown/McAnally
COMPLEAT Coming to Chicago area, June 1
style notation:
"Antigua and Barbuda (+1268)"[/\(\+\d+\)/] # "(+1268)"
David
--
David A. Black, Senior Developer, Cyrus Innovation Inc.
THE Ruby training with Black/Brown/McAnally
COMPLEAT Coming to Chicago area, June 18-19, 2010!
, coming up in
January 2010 in Tampa, Florida. Your hosts/instructors will be:
* David A. Black
* Gregory Brown
* Jeremy McAnally
We'll be exploring four areas of Ruby language features and
techniques, using a workshop-style approach that will include
instruction, hands-on exer
ug dump of a Feature
that has no owner_id.
David
--
The Ruby training with D. Black, G. Brown, J.McAnally
Compleat Jan 22-23, 2010, Tampa, FL
Rubyist http://www.thecompleatrubyist.com
David A. Black/Ruby Power and Light, LLC (http://www.rubypal.com)
--~--~-~--~~---
The Ruby training with D. Black, G. Brown, J.McAnally
Compleat Jan 22-23, 2010, Tampa, FL
Rubyist http://www.thecompleatrubyist.com
David A. Black/Ruby Power and Light, LLC (http://www.rubypal.com)
--~--~-~--~~~---~--~~
You received this message be
syms.each do |attr|
define_method("#{attr}=") do |value|
write_attribute(attr, BLANKS.include?(value) ? nil : value)
end
end
end
normalize_fields :address, :city, :country_id
end
David
--
The Ruby training with D. Blac
define_method("#{attr}=") do |value|
@blanks ||= [0, "0", "", " "]
write_attribute(attr, @blanks.include?(value) ? nil : value)
end
end
David
--
The Ruby training with D. Black, G. Brown, J.McAnally
Compleat Jan 22-23, 2010,
ment.illustration =
some_picture would mean that a given picture belonged to this comment.
Or... you could decide that the comment also belongs to the picture it
contains, with a distinct foreign key and so forth, though that might
feel a bit inside out.
David
--
David A. Black, Director
Ruby P
database=mysql
If you've already created the app, do the above on a second app, then
look at config/database.yml and you'll see the difference in
configuration (which you can then adapt for your original app by
editing its database.yml).
David
--
David A. Black, Director
Ruby Po
item in DB or not?
> I'm having issues.
Yes, it will save the item (assuming Order has many Items, Item
belongs to Order). If it doesn't, something else is wrong (like the
item not being valid).
David
--
David A. Black, Director
Ruby Power and Light, LLC (http://www.rubypal.com)
Rub
t;x_with_y"; end
p Base.instance_methods(false).sort # does not include "x"
include M
p Base.instance_methods(false).sort # does include "x"
end
end
AR::Base.new.x
After alias_method_chain, AR::Base has an "x" method, so overriding
the one in
ecent answer in ruby-talk; there is, indeed an
alias_method_chain call involving write_attribute (but not
read_attribute) that happens before the initializer is executed.
David
--
David A. Black, Director
Ruby Power and Light, LLC (http://www.rubypal.com)
Ruby/Rails training, consulting, mentorin
include that module (or extend an object with it or whatever).
David
--
David A. Black, Director
Ruby Power and Light, LLC (http://www.rubypal.com)
Ruby/Rails training, consulting, mentoring, code review
Book: The Well-Grounded Rubyist (http://www.manning.com/black2)
--~--~-~--~~--
n examine directly in irb or with ri.
David
--
David A. Black, Director
Ruby Power and Light, LLC (http://www.rubypal.com)
Ruby/Rails training, consulting, mentoring, code review
Book: The Well-Grounded Rubyist (http://www.manning.com/black2)
--~--~-~--~~~---~--~--
Hi --
On Wed, 16 Sep 2009, Felix Schäfer wrote:
>
>
> Am 16.09.2009 um 15:03 schrieb David A. Black:
>
>>
>> On Wed, 16 Sep 2009, steve bell wrote:
>>
>>>
>>> Hi there, just starting to get my head around routes but have a
>>> problem tha
Hi --
See my answer on ruby-talk.
David
--
David A. Black, Director
Ruby Power and Light, LLC (http://www.rubypal.com)
Ruby/Rails training, consulting, mentoring, code review
Book: The Well-Grounded Rubyist (http://www.manning.com/black2
t; in the routes.rb file?
You need to invert the logic:
map.resources :buzzwords, :controller => "terms"
David
--
David A. Black, Director
Ruby Power and Light, LLC (http://www.rubypal.com)
Ruby/Rails training, consulting, mentoring, code r
us of that when the record is being saved?
You have an after_create hook. Is it possible that that hook is doing
something that's making the record invalid after it's already been
saved?
David
--
David A. Black, Director
Ruby Power and Lig
;=>"third item"},
"345698067"=>{"description"=>"first item"},
"345698068"=>{"description"=>"second item"}},
"commit"=>"Buy",
etc. }
So now I can iterate through that hash, getting the
.save
Should that be @part.save? If so, I'm not sure why it doesn't blow up
entirely, but anyway, that was the first thing that struck my eye.
David
--
David A. Black, Director
Ruby Power and Light, LLC (http://www.rubypal.com)
Ruby/Rails training, consulting, mentoring, code review
Book:
Hi --
On Sat, 12 Sep 2009, steven_noble wrote:
Theory number two:
> form_for(@project, @part) do |f|
Try this:
form_for([...@project, @part]) do |f|
(i.e., put them in an array).
Theory number one still applies, though, in case you run into further
trouble :-)
David
--
Davi
I create new action paths to all my resources with the same code.
Do you mean you're using the same template for all of these views? I
can't quite get my bearings in the sequence of events you're
describing.
David
--
David A. Black, Director
Ruby Power and Light, LLC (ht
phone
> end
>
> where variable was work, for example. But it throws an error "Unexpected
> STRING_BEG". If there a way to do what I am doing? Thanks,
Yes:
@user.send("#{variable}=", @phone)
David
--
David A. Black | training
parentheses
appear, left to right (unless you use (?:) to suppress inclusion of a
particular group).
David
--
David A. Black / Ruby Power and Light, LLC / http://www.rubypal.com
Ruby/Rails training, mentoring, consulting, code-review
Latest book: The Well-Grounded Rubyist (http://www.manning.c
27;Book#authors_books' on '#'. Both records must have an id in
> order to
> create the has_many :through record associating them.
Just looking at it quickly I suspect that it's because you're trying
to add an Author to an unsaved Book record, and that it's impossi
x27;account.dropzone_id = ?', proxy_owner.id],
That should be accounts (plural) I suspect.
David
--
David A. Black / Ruby Power and Light, LLC / http://www.rubypal.com
Ruby/Rails training, mentoring, consulting, code-review
Latest book: The Well-Grounded Rubyist (http://www.mann
rogramming, and more.
OK, back to carbon copy mode :-)
***
The training is September 14-17, in Edison, NJ.
For more information: http://rubyurl.com/vmzN. And please feel free to
contact me with any questions!
David
--
David A. Black / Ruby Power and
h the model classes and
objects; those classes and objects have a dimension of depth into the
database and so forth. I'll mull it over and report back :-)
David
--
David A. Black / Ruby Power and Light, LLC / http://www.rubypal.com
Q: What's the best way to get a really solid knowledge
alized find operation and the
delivery into a model, so the controller could just do this:
User.mail_to_staff
or
Notifier.notify_staff
But in the simple case, where all you need to do is call a single
class method of ActionMailer, there's no reason not to just call it
from the contro
ontroller and/or User model tests.
David
--
David A. Black / Ruby Power and Light, LLC / http://www.rubypal.com
Q: What's the best way to get a really solid knowledge of Ruby?
A: Come to our Ruby training in Edison, New Jersey, September 14-17!
Instructors: David A. Black and Erik Kastn
...
and so on. I don't think it's necessary to wrap it in another layer of
modeling. Controllers are allowed to be one step away from model
logic, and the methods to deliver are already built into the
ActionMailer models.
David
--
David A. Black / Ruby Power and Light, LLC / http://w
g". It's just Ruby, updated for 1.9.1, lots of
new stuff, all the old stuff reviewed and revised, no Rails. (I want
to emphasize the no Rails thing so that I don't get any disgruntlement
when people buy it and find that there's no Rails :-)
David
--
David A. Black / Ruby Po
? It is the "Well Grounded Rubist."
Well, strictly speaking: The Well-Grounded Rubyist :-)
> everyone knows that you cannot groom a Rubist
And even if you could, you probably wouldn't want me as your
instructor :-)
David
--
David A. Black / Ruby Power and Light, LLC / h
er submitting it. If your
anecdote is chosen, you'll get a free copy of the book when it comes
out!
You can submit one or more anecdotes here:
http://anecdotes.rubypal.com
Let me know if any questions or problems. Thanks!
David
--
David A. Black / Ruby Power and Light, LLC / http://www.ruby
Hi --
On Wed, 22 Jul 2009, Hemant Bhargava wrote:
>
> David A. Black wrote:
>> Hi --
>>
>> On Wed, 22 Jul 2009, Hemant Bhargava wrote:
>>
>>> So no solution .. is it .. ?
>>
>> Hashes in Ruby 1.9 are ordered by key insertion order.
>>
>
Hi --
On Wed, 22 Jul 2009, Hemant Bhargava wrote:
> So no solution .. is it .. ?
Hashes in Ruby 1.9 are ordered by key insertion order.
David
--
David A. Black / Ruby Power and Light, LLC
Ruby/Rails consulting & training: http://www.rubypal.com
Now available: The Well-Grounded
bnq
which is a case for the affirmative :-) We'd be glad to see you.
Contact me any time if you have questions about the course. Thanks!
David
--
David A. Black / Ruby Power and Light, LLC
Ruby/Rails consulting & training: http://www.rubypal.com
Now available: The Well-Grounded Rubyist (h
Hi --
On Tue, 21 Jul 2009, Frederick Cheung wrote:
>
>
> On Jul 21, 12:02 am, "David A. Black" wrote:
>> You can do this and get, by coincidence, something like the desired
>> effect:
>>
>> def x=(val)
>> super
>> # do oth
her stuff
end
because the call to super will trigger AR::B#method_missing, but the
more I look at it and play around with it, the more I think it's way
too fragile and too closely couple to the method_missing
implementation to use.
David
--
David A. Black / Ruby Power and Light, LLC
Ru
Hi --
On Mon, 20 Jul 2009, Learn By Doing wrote:
> On Jul 19, 8:03 pm, "David A. Black" wrote:
>> Hi --
>>
>>
>>
>> On Sun, 19 Jul 2009, Learn By Doing wrote:
>>
>>> On Jul 19, 6:39 pm, "David A. Black" wrote:
>>>&g
so forth.
So there are two things going on here: the instance variable itself
(which is visible in the master template and the partial), and the
local variable "foo" in the partial, which you have initialized to the
same value as @recent_messages. If you use "recent_messages&quo
n't think this is actually a singular/plural
issue.
David
--
David A. Black / Ruby Power and Light, LLC
Ruby/Rails consulting & training: http://www.rubypal.com
Now available: The Well-Grounded Rubyist (http://manning.com/black2)
Training! Intro to Ruby, with Black & Kastner, Se
starting at the
simplest case: if you have this in your routes.rb:
map.namespace :admin do |a|
a.resources :news
end
and if @news is a News object, and you've got an admin/news
controller, you should be OK.
David
--
David A. Black / Ruby Power and Light, LLC
Ruby/Rails consult
Hi --
On Sun, 19 Jul 2009, Learn By Doing wrote:
>
> On Jul 19, 6:39 pm, "David A. Black" wrote:
>> Hi --
>>
>>
>>
>> On Sun, 19 Jul 2009, Ease Bus wrote:
>>> Hi,
>>
>>> I would like to rename the sett
uperclass with a definition for
the attribute_A= method? (I'm trying to figure out why you're calling
super.)
David
--
David A. Black / Ruby Power and Light, LLC
Ruby/Rails consulting & training: http://www.rubypal.com
Now available: The Well-Grounded Rubyist (http://manning.com/black2
0
>> send(:x=, 20)
=> "Explicit return value"
(Thanks to Rick DeNatale for reminding me of the send thing in a
recent ruby-talk thread about this :-)
But using send with a = method kind of defeats the purpose.
David
--
David A. Black / Ruby Power and Light, LLC
Ruby/Ra
ot; meaning that it won't call private methods, I assume -- but
that decision was rescinded.
David
--
David A. Black / Ruby Power and Light, LLC
Ruby/Rails consulting & training: http://www.rubypal.com
Now available: The Well-Grounded Rubyist (http://manning.com/black2)
Training! Intro
e was some question which was the
"dangerous" one: the one that included private methods, or the one
that didn't.
It appears to be gone from Rails, so maybe it was only there during
the brief period that it was in 1.9.
$ ./script/console
Loading development environment (Rails 2.3.2)
On Tue, 14 Jul 2009, Rick DeNatale wrote:
>
> On Tue, Jul 14, 2009 at 8:46 AM, David A. Black wrote:
>>
>
>> I think you're overthinking it. There's no inherent connection between
>> constants and class methods.
>>
>> module MyMathModule
>>
I run the above
under Ruby 1.9.1:
In C#m: [1, 2, 3]
sup.rb:22:in `block in ': implicit argument passing of super
from method defined by define_method() is not supported. Specify all
arguments explicitly. (RuntimeError)
from sup.rb:27:in `'
In other words, you can't do it any m
he
application itself, so I'm being kind of mechanistic about moving code
around (and haven't tested it), but that's at least a broad-stroke way
of rethinking it.
(Another thing to think about would be whether the calculation method
might belong in a class, rather than as a top-level
yellow green blue indigo violet }
def show_me_the_colors
puts "My colors are: #{COLORS.join(", ")}"
end
end
r = Rainbow.new
r.show_me_the_colors
=> My colors are: red, orange, yellow, green, blue, indigo, violet
David
--
David A. Black / Ruby Power and
s object Something.
There's a bit more to it, but am I on the right track, in terms of
what you're finding confusing?
David
--
David A. Black / Ruby Power and Light, LLC
Ruby/Rails consulting & training: http://www.rubypal.com
Now available: The Well-Grounded Rubyist (http://manning
just create hashes directly, and so on.
As I say, there are probably more turnkey-ish ways to do it already
out there somewhere, though I find it pretty turnkey-ish anyway.
There's also rake db:fixtures:load, if you happen to have the sample
data you want already in the test fixtures.
Davi
o see you there!
David, for David and Erik
--
David A. Black / Ruby Power and Light, LLC
Ruby/Rails consulting & training: http://www.rubypal.com
Now available: The Well-Grounded Rubyist (http://manning.com/black2)
Training! Intro to Ruby, with Black & Kastner, September 14-17
More info:
ay which is why the covers at
Manning and Amazon are different at the moment. Same book though :-)
[1] http://manning.com/black2
[2] http://tinyurl.com/twgramz
--
David A. Black / Ruby Power and Light, LLC
Ruby/Rails consulting & training: http://www.rubypal.com
Now available: The Well-Gro
make sure
it's OK, I request a representation (probably in the form of an HTML
document) to inspect.
I've written a bit more about this on these blog posts:
http://dablog.rubypal.com/2008/3/23/splitting-hairs-over-resource
http://dablog.rubypal.com/2008/4/24/splitting-hairs-over-resource-part-2
specifi
ublic/register. I believe the pricing
is the same as last year.
David
--
David A. Black / Ruby Power and Light, LLC
Ruby/Rails consulting & training: http://www.rubypal.com
Now out in PDF: The Well-Grounded Rubyist (http://manning.com/black2)
"Ruby 1.9: What You Need To Know" Envyca
and Part 2 separately, or get them together for a
discount. It's a great way to get your bearings in 1.9 and learn some
cool and useful things about strings and encoding, arrays, hashes,
enumerators, the new block variable rules, and more.
More info at: http://www.envycasts.com
Enjoy!
David
-
ance to learn Ruby really well from top-notch instructors.
Any questions can be sent to me directly. Thanks!
David
--
David A. Black / Ruby Power and Light, LLC
Ruby/Rails consulting & training: http://www.rubypal.com
Coming in 2009: The Well-Grounded Rubyist (http://manning.com/black2)
Ruby
e on twitter as david_a_black.
Ruby Training Atlanta is a joint venture of ENTP and Ruby Power and
Light. Looking forward to it!
David
--
David A. Black / Ruby Power and Light, LLC
Ruby/Rails consulting & training: http://www.rubypal.com
Coming in 2009: The Well-Grounded Rubyist (http://mannin
& Conference Center.
More information, and registration, at:
http://www.entp.com/training/atlanta09
and you can email me directly if you have any questions.
See you there!
David
[1] http://www.rubypal.com
[2] http://www.entp.com
--
David A. Black / Ruby Power and Light, LLC
Ruby/Rai
Hi --
On Wed, 21 Jan 2009, Mohammad Abed wrote:
>
> Hmm! If the I Sign in to the site. I type the url "mysite.com/galleries"
> I get a different error
Getting a different error is always a hopeful sign :-)
> "undefined method `elseif' for #"
It's
leries
One way or another, current_user is returning nil. So you'd have to
track that down and fix it, or work around not having a current user
in this action.
David
--
David A. Black / Ruby Power and Light, LLC
Ruby/Rails consulting & training: http://www.rubypal.com
["visibility_status = ?", true]
Then you can do:
@galleries = user.visible_galleries
or something like that, in the controller, instead of in-lining the
business logic of the model.
David
--
David A. Black / Ruby Power and Light, LLC
Ruby/Rails consulting & training: http://www.
th_date)
(or some small variations on that) you'll get @person.birth_date in
the field automatically.
David
--
David A. Black / Ruby Power and Light, LLC
Ruby/Rails consulting & training: http://www.rubypal.com
Coming in 2009: The Well-Gro
t;
> map.resources :scanns, :member => { :query => :any }
>
> In this case, what I want is to show a page with a form for enter data
> and later query the database.
>
> I could make it work with other Rails versions but not with the last one
> ...
>
> What can be wro
the
file did you define a constant called "Payment_type". What you really
want is for Rails to be looking for the constant PaymentType, not
Payment_type, and that's why you need to correct your Payment_type
references to PaymentType. (And in any case, you need to use the same
name
vironment.rb (I did have
> it in prodcution.rb) and I now get an error:
>
> ...s/config/environment.rb:13:NameError: uninitialized constant
> ActionMailer
Try moving all that ActionMailer lines to the end of the file (after
the RailsInitializer.run block is over).
David
--
David A.
ionality or for speed), except it's already served one of its
purposes, namely to help me learn more about the recent controller
code and the implementation of the middleware integration. Anyway, if
interested, have a look, and let me know if you have any
comments.
David
--
David A. Black / Ruby
a users controller, I would probably favor a create action in a loans
controller, simply because it converges more predictably on the
CRUD-related semantics of the resource routing.
David
--
David A. Black / Ruby Power and Light, LLC
Ruby/Rails consulting & training: http://www.rubypal.com
Coming
ed and
params[:book] is nil, what would you want to happen? And, as a
follow-up, does your current error-reporting process already do what
you would want to have done in such a case?
David
--
Rails training from David A. Black and Ruby Power and Light:
IN
r-the-restless
(Or you might be past the point where it's useful, but I thought I'd
throw it out there just in case.)
David
--
Rails training from David A. Black and Ruby Power and Light:
INTRO TO RAILS (Jan 12-15), Fort Lauderdale, FL
See http://www.rubypal.com for d
ge|%>
> <%= side_image.filename.to_s %>
><%end>
>
> Then Rails allows me to access the attribute directly. I'm certainly
> doing something wrong with instance variables assignments/declarations.
Is the code you're showing us cut-and-pasted from your vi
Hi --
On Sat, 29 Nov 2008, DyingToLearn wrote:
>
> packat wrote:
>> If you are to buy a Ruby on Rails book
>> right now, which book would you choose?
>
> Ruby for Rails by David A. Black. It is a bit old, but still extremely
> relevant. I found the Ruby parts to be a
oincide with what you want,
that's great. Otherwise, I'd avoid it. There's no reason to give it
first refusal of your development space, just because it's there.
David
--
Rails training from David A. Black and Ruby Power and Light:
INTRO TO RAILS (Jan 12-15), Fort Lauderda
lines and registration links,
at http://www.rubypal.com, and please contact me directly with any
questions. I'll also be at RubyConf next week and happy to discuss the
training there.
David
--
Rails training from David A. Black and Ruby Power and Light:
Intro to Ruby on Rails January 12
e method
names in your own code.
David
--
Rails training from David A. Black and Ruby Power and Light:
Intro to Ruby on Rails January 12-15 Fort Lauderdale, FL
Advancing with RailsJanuary 19-22 Fort Lauderdale, FL *
* Co-taught with
/\W+/, '-')
\W does not include underscore (which is part of the \w class), so if
you want to translate underscores you would do:
/[\W_]+/
David
--
Rails training from David A. Black and Ruby Power and Light:
Intro to Ruby on Rails January 12-15 Fort Lauderdale, FL
Advancin
he event and the program at:
http://2008.rubyconf.org
If you have any questions you can write directly to me, or to
[EMAIL PROTECTED]
See you in Orlando!
David
--
Rails training from David A. Black and Ruby Power and Light:
Intro to Ruby on Rails January 12-15 Fort Lauderdale, FL
86 matches
Mail list logo