mentby.com
Blog | Jobs | Help | Signup | Login

loading
I have defined a rake task inside an engine like this:

rake app:redmine_config:spec

namespace :my_engine do
  
  desc "say foo"
  task :foo do
    puts "foo from the engine"
  end

end

I expected the task to be available under

rake my_engine:foo

instead I found it under:

rake app:my_engine:foo

Does anybody have an idea where the prefix comes from? Can I change it? Can
I get rid of it?

thx for any help,
stefan

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To view this discussion on the web visit  https://groups.google.com/d/msg/rubyonrails-talk/-/ZXmbOmB_3[..]
To post to this group, send email to rubyonrails-talk*******.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe*******.
For more options, visit this group at  http://groups.google.com/group/rubyonrails-talk?hl=en-US.
I have an engine and can access model-classes of the hosting app without
any troubles.

But when I try to access classes that are defined in the lib-directory of
the hosting app, they are not found and I get a

uninitialized constant Redmine

where Redmine is a module defined in the lib-directory of the hosting app.
The lib-directory has added this dir to the autoload_paths, but the engine
does not see them. The documentation
( http://api.rubyonrails.org/classes/Rails/Engine.html ) here is a litte
vague:

The Application class adds a couple more paths to this set. And as in your
Application, all folders under app are automatically added to the load
path. If you have an app/observers folder for example, it will be added by
default.

but the paths defined as autoload_paths are not added by default?!

Is there a way I can get the engine to load the classes in the lib-dir of
the hosting app?!

thx for any help,
stefan

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To view this discussion on the web visit  https://groups.google.com/d/msg/rubyonrails-talk/-/jMVWKss3T[..]
To post to this group, send email to rubyonrails-talk*******.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe*******.
For more options, visit this group at  http://groups.google.com/group/rubyonrails-talk?hl=en-US.

Read more »

I'm currently trying to convert an existing non-engine-plugin (for redmine)
into an engine: Here I ran into some routing issues: a controller in the
plugin uses a layout from the hosting application, the hosting application
now tries to render links inside this layout within the context of the
plugin's controller, which fails, as the plugin does not define them, only
the hosting application does.

the edgeguide on routes( http://edgeguides.rubyonrails.org/engines.html#routes ) says, qualifying the
main.app will solve this issue:

<pre>
link_to "Home", main_app.root_path
</pre>

however, I cannot/do not want to rewrite *all* the links in the hosting
application: Is there a way to have rails fall back on the links of the
hosting-application, when a route is not found in the plugin?

A somewhat similar problem happens, when I use link_to with an url like:

<pre>
link_to "My Account", {:controller => "my",:action => :account}
</pre>

which works fine, when called from the hosting-application(as the
my-controller exists there, but get's prefixed with the plugin's namespace,
when it is called from within a controller inside the plugin, which gives
a:

<pre>
ActionController::RoutingError (No route matches
{:controller=>"redmine_config/my", :action=>"account"}):
</pre>

as the plugin does not define the my-controller.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To view this discussion on the web visit  https://groups.google.com/d/msg/rubyonrails-talk/-/MM1fRQ30_[..]
To post to this group, send email to rubyonrails-talk*******.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe*******.
For more options, visit this group at  http://groups.google.com/group/rubyonrails-talk?hl=en-US.

Read more »

Group(s)
Recent discussion with
Profile Widget
Copy and paste this HTML code to your blog or website: