Artod
Artod

Reputation: 901

How to make a public folder in my rails plugin?

How to make a public folder in my rails plugin?

For example, I have image in /my_rails_app/vendor/plugins/my_plugin/public/edit.gif but in http://localhost:3000/edit.gif i got routing error.

Upvotes: 1

Views: 1162

Answers (2)

Andrew
Andrew

Reputation: 11

You can put the image in public/uploads/edit.gif.

Then you can visit it via

http:// localhost:3000/uploads/edit.gif

I tested on my rails server and it works.

Upvotes: 1

gertas
gertas

Reputation: 17145

Directly you can't use it. Plugins /public are not merged with main /public folder by default. Generally on deployment it is common to map only main /public but nobody exposes plugin's to viewers.

You have to prepare rake task or generator which copies these files to apps /public folder.

Generally it may be possible to do some routing trickery but generally I'm not recommending it.

Upvotes: 2

Related Questions