Closed GoogleCodeExporter closed 9 years ago
Is this still an issue with 677 being fixed?
Original comment by mr.ga...@gmail.com
on 6 Apr 2009 at 4:14
[deleted comment]
This is still the case. Im using todays clone of active_scaffold, with Ruby
1.9.1
and Rails 2.3.2.
Example:
active_scaffold :table do |config|
# config == nil
config.columns.exclude :created_at, :updated_at
# errror raised
end
test = active_scaffold :table
# test == [:create, :list, :search, :update, :delete, :show, :nested, :subform]
Original comment by Sickboy....@gmail.com
on 13 Apr 2009 at 12:36
Looks like it works if you do this (for example):
active_scaffold :table do
self.columns.exclude :created_at, :updated_at
end
instead of:
active_scaffold :table do |config|
config.columns.exclude :created_at, :updated_at
end
Original comment by McClella...@gmail.com
on 21 Apr 2009 at 7:07
Original comment by mr.ga...@gmail.com
on 24 Apr 2009 at 3:02
So does that mean what I said above is the new way to do things ... ? Shouldn't
the
docs be updated to reflect that change? Isn't this kind of a biggie?
Original comment by McClella...@gmail.com
on 24 Apr 2009 at 3:06
It's a ruby change in instance_eval, we can't fix it, and I think self.colums
works
in ruby 1.8 too. Please, add examples in the wiki docs where you think is
needed.
Original comment by sergio.c...@gmail.com
on 24 Apr 2009 at 3:33
This is also an issue with ActiveScaffold.set_defaults, the suggested fix above
(remove |config| and do
'self.config') does not work for set_defaults.
This will have to be fully resolved.
I'm sure that the normal syntax _can_ work on Ruby 1.9, since all the Rails
stuff (like Routes) still works. It might
mean a change in the eval process for ActiveScaffold, but I'm sure it is
possible.
Original comment by adam.q.salter@gmail.com
on 8 Sep 2009 at 4:25
The problem is block is eval in its own binding and in configuration binding, so
instance_eval is used. instance_eval was changed in ruby 1.9 and it doesn't
work in
that way. Rails stuff like routes doesn't use instance_eval, they pass the
object to
the block.
Probably the best way would be passing self to the block and removing
method_missing, so block will be eval only in its own binding, but it would
break
backwards compatibility, for example I have some code which relies in this
feature,
although I did it without be aware of it (I used model inside the block,
instead of
config.model)
I have changed instance_eval to instance_exec passing self to the block. It
works in
ruby 1.8 (due to active_support adds instance_exec which is a ruby 1.9 method).
Can
you try with ruby 1.9?
Original comment by sergio.c...@gmail.com
on 8 Sep 2009 at 10:21
Yes that works on first blush (didn't run tests):
Change line 11 of lib/active_scaffold/configurable.rb to:
ret = configuration_block.call(self)
Wow, I tried experimenting with this previously and couldn't quite work it
out... yields and block and calls... :)
Original comment by adam.q.salter@gmail.com
on 8 Sep 2009 at 10:34
Umm.. looking at your comment I suspect I got it wrong... what was the exact
code you wanted me to try?
Original comment by adam.q.salter@gmail.com
on 8 Sep 2009 at 10:42
I'm happy to run any tests you want against ruby 1.9, so if you point me to
your repo once you apply change, I'll
fork and test.
Original comment by adam.q.salter@gmail.com
on 8 Sep 2009 at 10:46
ret = configuration_block.call(self)
This line can work, but then you can't use model (while you can use with ruby
1.8
now), you must use config.model, so that line breaks backwards compatibility.
I want you try
ret = instance_exec(self, &configuration_block)
which is in master
Original comment by sergio.c...@gmail.com
on 8 Sep 2009 at 10:48
Yes that works with method missing as well.
so both model and config.model work.
Thanks for quick response.
Original comment by adam.q.salter@gmail.com
on 8 Sep 2009 at 11:18
Original issue reported on code.google.com by
dale.hof...@gmail.com
on 3 Apr 2009 at 1:46