ay 18, 6:11 pm, Michael Koziarski wrote:
> On Wed, May 18, 2011 at 11:52 AM, Kristian Mandrup wrote:
> > I'm curious whether you can define the :as option as a list of roles?
> > All the examples I have seen only has the :as linked to the single
> > role :admin.
>
> In
I'm curious whether you can define the :as option as a list of roles?
All the examples I have seen only has the :as linked to the single
role :admin.
How would I use this with a roles system?
Say I had a #current_user_roles method available from my Controller or
whatever.
def update
Project.upd
All I actually wanted to do was to add some helper methods for my
views.
I kind of "solved" the problem by rethinking my approach, as I could
see I had gone down a "blind alley".
module ApplicationHelper
def self.auth_assist_helpers
include AuthAssistant::ViewHelpers
end
end
module AuthAs
Trying to use the "smart" API for link_to
def create_link(object, label = nil)
label ||= auth_labels[:new]
link = link_to(label, [:new, object]) if can?(:create, object)
link.sub /new\./, 'new/'
end
But this generates a link like /projects/new.1 , instead of /projects/
new
I would assu
I have ben struggling the past two days getting a this tiny piece of
functionality to work without any success :(
Trying to add a simple helper method to my views in order to ensure
links are only displayed if the user has the proper rights to access
that functionality.
def show_link(object
I'm having problems using url_for in a controller. The original method
looks like this, but the @controller variable is unknown in this
context. However if I remove it, it goes in an endless loop for the
Hash case. Anyone?
def url_for(options = {})
options ||= {}
url = case o
I had a need for accessing the methods in
ActionView::Helpers::UrlHelper in my controllers to conditionally
return link HTML to my views depending on login state etc.
I think that the UrlHelper should by default be added to all
Controllers and methods such as link_to made available for views using
It turned out I had to include the require statement in an
initializer. Putting it in the application.rb didn't work (not found
error). I has to due with the load order I'm sure.
Thanks for the help :)
>
> I think you still need to require it in the application.rb file. I might be
> wrong as I ha
Yes, it worked by inserting the require statements in the
initializers.
On May 12, 12:00 pm, Kristian Mandrup wrote:
> How does the lib folder work in Rails 3?
>
> In Rails 2.x you would add require statements in application.rb, fx:
>
> /lib
> blip.rb
>
>
OK, it seems it works using autoload, being lazy loaded when accessed.
But what if I want to force it to be loaded when rails starts?
Appending a require 'blip' in application.rb I am told no such file
exists!? Would I have to insert it in an initializer?
# lib/blip.rb
puts "Blip loaded!"
class
How does the lib folder work in Rails 3?
In Rails 2.x you would add require statements in application.rb, fx:
/lib
blip.rb
# blip.rb
puts "BLIP"
# application.rb
...
require 'blip'
---
But using the same approach doesn't work in Rails 3. How do I
configure this so that blip.rb is loaded when
On a further note. I can't seem to get any .rb files in RAILS_ROOT/lib
to load when I start my rails server.
Say I have a file
# lib/auth_assistant.rb
puts "Hello from AuthAssist"
--
In the old days of Rails 2.3+ you would put a require statement in
application.rb, but I think in Rails 3 all fil
ere... any idea how to do this?
I could hack it using "run" which works, but produces:
run rails g migration add_admin_field_to_user admin:boolean from "."
Which just doesn't feel right ;)
Thanks!
On May 12, 10:27 am, Anuj Dutta wrote:
> On 12 May 2010 19:55, Kri
I worked it out myself. It had to do with the fact that the generators
for some reason require the namespace to match a containing folder,
much like the Java package mechanism.
lib/generators
- auth_asisst
- ability
ability_generator.rb
# ability_generator.rb
module AuthAssist
module G
Hi,
I've been trying to develop a Rails gem/plugin with generators for
Rails 3. I first had a separate gem project with a gem statement in my
Gemfile with a :path option to point at it. But then I had to run $
rake install on each change in my gem to have Rails pick up on it. I
have now instead pu
Thanks! That works :)
On May 11, 4:25 am, Yehuda Katz wrote:
> Can you try 1.9.2-head?
>
> Yehuda Katz
> Architect | Engine Yard
> (ph) 718.877.1325
>
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Core" group.
To post to this group, send email to
First tried creating default Rails app using Rails 3-beta3
$ rails simple
$ mate Gemfile
gem 'rails', '3.0.0.beta3'
$ cd simple
simple kristianconsult$ rails s
/Users/kristianconsult/.rvm/gems/ruby-1.9.2-preview1/gems/
activesupport-3.0.0.beta3/lib/active_support/values/time_zone.rb:
208:in `u
Thanks. I've just been away from Rails dev for a bit too long...
# Bundle edge Rails instead:
gem 'rails', :git => 'git://github.com/rails/rails.git'
On May 10, 7:09 pm, Michael Koziarski wrote:
> On Tue, May 11, 2010 at 11:01 AM, Kristian Mandrup wrote:
>
Hmm, I guess I could just clone github rails and then use the :path
option in my Gemfile to point to that version, but is there another
way?
On May 10, 3:58 pm, Kristian Mandrup wrote:
> I get an error using Rails 3 beta3 on Ruby 1.9.2-preview1
>
> undefined method `current_pe
I get an error using Rails 3 beta3 on Ruby 1.9.2-preview1
undefined method `current_period' for nil:NilClass (NoMethodError)
This commit should fix it
http://github.com/rails/rails/commit/a0cc94b32e5b4e4dce50787eed1208406f99ea82
But I forgot how to ensure I am running on edge with Rails 3.
Is i
I have been trying to upgrade the translate_routes plugin from Rails 2
to 3.
Looking into the Rails 3 source, I can't seem to gem a grip on how the
Path Segments are handled now.
Maybe it has to do with the new Rack way of doing things?
Fx a url could have a date at the end in the form of :yy/:mm/
Thank you so much! Just what I was looking for. I knew there had to be
a way... It doesn't seem like the :path option is mentioned much
however.
On Apr 19, 6:42 pm, Mislav Marohnić wrote:
> First of all, this is not a list to discuss Bundler features or development.
> Ask on #carlhuda Freenode ch
If I have a gem locally that I change without updating the version
number the bundler never seems to notice.
I have a gem fx 'devise-assistant' version 0.1.0. If I add a single
method and run 'rake install' and then 'bundle install' in my Rails
app, then bundler seems to think the gem has not been
$ rails g stylesheet
Could not find generator stylesheet.
I guess not... but
http://github.com/rails/rails/tree/master/railties/lib/rails/generators/rails/stylesheets
contains a stylesheets generator
$ rails g
Please choose a generator below.
Rails:
controller
generator
helper
integrat
$ gem install mongrel --source http://gems.rubyinstaller.org
mongrel 1.1.6 installed
# Gemfile
gem "mongrel"
gem "cgi_multipart_eof_fix"
gem "fastthread"
$ rails s
=> Booting Mongrel
=> Rails 3.0.0.beta3 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-
I first tried a simple
gem 'mongrel'
Then later the solution found here
http://jan.varwig.org/archive/rails-3-and-mongrel
gem "mongrel"
gem "cgi_multipart_eof_fix"
gem "fastthread"
gem "mongrel_experimental"
But still can't get it to work...
Anyone?
--
You received this message because you
OK, the tutorial must have been for beta2. Now error_messages is a
plugin!
rails plugin install git://github.com/rails/dynamic_form.git
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Core" group.
To post to this group, send email to rubyonrails-c...
Also using
<%= form.error_messages %>
to display error messages, only results in this output:
Where is the bullet list of errors? Strange!
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Core" group.
To post to this group, send email to rubyonrai
It turns out that Yehuda seems to have 'cheated' a little with the
screencast. The app needs the scaffold.css.
http://github.com/rails/rails/blob/master/railties/lib/rails/generators/rails/stylesheets/templates/scaffold.css
Is there a way to generate this stylesheet without scaffolding?
--
You
I have just been following the updated 15 min blog tutorial by Yehuda
http://www.railsdispatch.com/posts/rails-3-makes-life-better
I noticed by browser outputs looked a bit weird. Then I discovered I
had no stylesheet generated.
Is this a known bug or what? Does someone have a link to the default
Since the idea of UJS is loose coupling, the UJS framework of choice
should be installed as a gem, just like we do for markup languages
such as Redcloth etc. Same goes for the template language IMO.
Rails doesn't even require any view frontend in many cases, fx when
using a javascript framework su
I have been trying to port the translate_routes plugin for use with
Rails 3.
The current version uses the old StaticSegments, but it looks like
this has now been simplified to simple strings.
How would I get the static parts of a registered route in Rails 3?
Would I have to parse the string mysel
I know the code could be much improved, fx the add_gem has so far no
support for an options hash.
Perhaps this could be integrated into the original
Rails::Generators::Actions in a new fork?
I will also work on a 'txt-mutator' gem with a DSL for general-purpose
code (text file) refactorings.
'thor
kristian-mandrups-macbook-pro:demo_app kristianconsult$ bundle install
Updating git://github.com/rails/rails.git
Updating git://github.com/rails/arel.git
Updating git://github.com/rails/rack.git
Updating git://github.com/rspec/rspec.git
Updating git://github.com/negonicrac/rspec-rails.git
Updating
Thanks to everyone!!!
I have been working a lot on this since this post and I have figured
it all out "with a little help from some friend".
I'm on Ruby 1.9.1, Rails 3.0 pre. Been creating a lot of nice new
Rails 3 generators, currently working on Rails 3 templates!!!
I have created a gem "txt_fi
I propose the following fix:
module Thor
class Actions
def append_line_file(file, txt, *args)
append_file file, "#{txt}\n", args
end
end
end
module Rails
module Generators
module Actions
def gem(*args)
options = args.extract_options!
name, version = a
Found it in rails/railties/lib/rails/generators/actions.rb
def gem(..)
...
in_root do
append_file "Gemfile", "gem #{parts.join(", ")}", :verbose =>
false
end
Should add a newline!
append_file "Gemfile", "gem #{parts.join(", ")}\n", :verbose => false
Or perhaps extend with a
When I use the Rails templates features and use the gem statemtent,
the gems in the Gemfile end up being appended without a newline like
the following:
mytemplate.rb
--
gem "rspec"
gem "cucumber"
gem "cucumber-rails"
--> Gemfile
gem "rspec"gem "cucumber"gem "cucumber-rails"
--
Not very pretty!
The solution was to add require 'rails' to my executable. But I still
see it as an odd edge case and a bit of a "hack"...
nifty_controller
--
#!/user/local/bin/ruby
...
require 'rails'
require 'rails/generators'
require 'generators/nifty/controller/controller_generator'
Nifty::Generators::C
When I run the generator as script/generate it works, but when I use
my executable calling the same controller it breaks. I have seen this
kind of error in other instances where I was able to fix it inside the
generator, but in this case the error seems to stem from a dependency
on rails internals?
I fixed it with a pretty ugly hack :P
def initialize(*args, &block)
super
@my_options ||= {}
...
if arg == '!'
@my_options[:invert] = true
...
if @model_attributes.empty?
@my_options[:skip_model] = true
def do_skip_model?
except I run into the following issue
module Nifty
module Generators
class ScaffoldGenerator < Base
...
def initialize(*args, &block)
super
args_for_c_m.each do |arg|
if arg == '!'
options[:invert] = true<< line 53
...
if @model_at
For inspiration I have been looking into rails 3.0pre
I found this in the file bin/rails
--
...
require 'rails/generators'
require 'generators/rails/app/app_generator'
Rails::Generators::AppGenerator.start
--
framework.task
--
...
desc "Applies the template supplied by LOCATION=/path/to/templa
Sounds great! How would I do that exactly?
http://yehudakatz.com/2008/05/12/by-thors-hammer/
--
Thor, as it exists today, has two components:
* The Thor superclass, which works exactly like CLI/Hermes, except
that you inherit from it instead of including it (class MyApp < Thor).
* The Tho
Hi,
I have been working a lot on getting a grasp of creating rails 3
generators.
I have created some nifty generators and some Mongo Mapper and Mongo
generators.
Now I am considering creating a complete Rails app generator, to
customize it to my needs.
It seems a bit akward to use the "current" a
I never managed to get the datamapper_on_rails3 app to work. I tried
to follow the instructions in the readme.
I always get this error when I try a scaffold inside the app:
kristian-mandrups-macbook-pro:datamapper_on_rails3 kristianconsult$
script/generate scaffold Profile nick:string
/Users/kristi
Here is my repo ;) Thanks!
http://github.com/kristianmandrup/datamapper_rails3_demo
> Hello Kristian,
>
> Sorry, I did not know you were doing that already. Right, so can you point
> me to your repository please and I will run it on my system and debug it.
>
> Thanks
>
> Anuj
>
>
> > > Just saw
Hi Martin and Anuj,
Thanks for the tip! I found your repo previously, but this is the pure
gem. I guess I would have to integrate it with the demo rails app or
maybe @Anuj could update his repo?
I will upload my current repo ASAP so you can have a look ;)
Thanks!
Kris
On Jan 27, 6:46 pm, Mart
Yes, for some reason it used to be that you would specify first the
model/controller name, then the attributes of the model and then the
actions of the generated controller.
Now you can only specify controller/model and attributes for some
reason.
Still, scaffold doesn't work at all with the rails
Hi Anuj Dutta,
Yes, I found rails3_datamapper by snusnu previously and had a look at
it since I also thought I could get some inspiration from it.
I think the repository you mention is an old one, my mongo_model_m3
repo works just fine, and I have a *generators* directory!
When I try to run scaff
So it works as long as I only specify controller/model and attributes
Here I set g.orm :mongo_model
But where do I map this orm symbol to the correct model generator I
wonder?
$ script/generate scaffold Person name:string
error mongo_model [not found]
route resources
I have installed Mongo DB and created my first Rails 3 model generator
as a gem, which can create Mongo Mapper models in a Rails 3 project :)
See http://github.com/kristianmandrup/mongo_model_r3
Also available from gemcutter as mongo_model 0.2.1.
I am now trying to create a scaffold generator us
$ script/generate scaffold Post name:string index
/Users/kristianconsult/my_rails/rails3_apps/r3_test/vendor/gems/ruby/
1.9.1/gems/activesupport-3.0.pre/lib/active_support/whiny_nil.rb:49:in
`method_missing': undefined method `to_sym' for nil:NilClass
(NoMethodError)
from /Users/kristiancon
Really great work!!!
Now we just need the community to write some good blog posts on how to
use all the new APIs ;)
I'm playing with Rails 3pre now, but running into some roadblocks on
the way...
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Core" g
54 matches
Mail list logo