How can I make my plugins work in a location other than "vendor" in Rails 3.2.8? - ruby-on-rails-3

I followed some instructions, which I'm unable to locate again, to move my plugins to the "lib" directory.
So I have this structure now:
/lib
/lib/plugins
/lib/plugins/plugin1
/lib/plugins/plugin1/lib
/lib/plugins/plugin1/lib/plugin1.rb
I had tried this in my application.rb:
config.autoload_paths += %W(#{config.root}/lib #{config.root}/lib/plugins)
But that isn't working. What am I doing wrong?
UPDATE:
Trashing the plugins part of the path and putting the plugins directory directly in doesn't work either. Each plugin has an init.rb file that basically requires the main library, also.

I'm not sure if these are the instructions you were following, but you probably want the plugin folder itself at the root of lib:
/lib
/lib/plugin1
/lib/plugin1/plugin1.rb
You also may need an initializer: config/initializers/plugin1.rb.
If that doesn't help, please post more information about what you're expecting to see and why it's not working.

Related

"no main manifest attribute" error in intellij when executing jar

I'm working on a kotlin project that I want to execute as a jar. This is all done in IntelliJ Idea and I went about making the jar using the artifacts.
The process I followed was (as illustrated by an Idea guide):
Add artifact (as jar) from project structure
Build jar
Run jar
After this, I get a
'no main manifest attribute, in ____.jar'
What I have tried after reading several stack overflow questions:
Checking that the manifest file is in the correct folder and has the correct path in the artifact
Adding code to the build.gradle file for the jar->manifest portion
Trying the method of moving the manifest stuff into a resources folder
Checking that the jar exists
Moving the manifest stuff into a different folder (java,kotlin,out folders)
Making sure that the manifest file is in the correct format
All of the above has not worked.
Something that is confusing to me is that, even when I alter the manifest file to be in "incorrect" format, it still gives the same error. The path stated in the artifact's details is correct yet there is no difference even when I purposely input incorrect items in the manifest file. Not sure if that is the"real" problem but I'm also not sure how to fix that as well
None of the solutions worked for me.
I solved it in this way:
When setting up the artifact, change:
Meta-inf: (...)\src\main\ (you must remove "java")
Also, there was a problem with resources, solved this way:
When setting up the artifact:
Output Layout > Add copy of > Directory content > resources.
That's all!
For anyone that may have encountered this problem in intellij and did not find a solution in any other posts, what helped me was
Navigating to Project Structure
Going to the Artifacts tab
Explicitly adding a new META-INF/ directory in my jar
Adding the created MANIFEST.MF file to the META-INF/ in the jar FROM THE ARTIFACTS TAB
Rearranging the order for the META-INF/ to be at the top
Building and running
The end result looked like this
while creating the exeutable jar file explicitly create a mainfest.txt file
that should be in order of the directory structure and mainfest.txt file should contain only one line (Main-Class:name of the class containg main method)then run the jar tool

How to force IntelliJ to use a different home folder

I have a computer with two hard drives. In the first one, an SSD disk, I have Windows partition (C) and on the second one (D), a raid volume, I install all the programs. I also moved my user folders (desktop, documents, downloads, pictures and videos) to D:/Users/David.
After installing IntelliJ Idea on D:/Program Filles(x86) a .IntelliJIdea13 directory appeared on D:/Users/David. No problem with this as all was working nice. Then I installed Scala plugin, created a new SBT project and build it. After this, the .sbt directory used by SBT was in C:/Users/David/.sbt but the references to the libraries in my project are pointing to D:/Users/David/.sbt. The question is, how can I force IntelliJ Idea or Scala plugin to download the libraries to D:/Users/David.sbt?
Not 100% sure if this can be a solution, you can change the HOME folder of Intellij IDEA. Look for the folder where the idea executable is. In Linux I have on
~/applications/idea13/bin
On Windows you can check the properties of the menu item. There should be file idea.properties that contains the home folder location of the idea files.
You can find more information here that describe more details:
Locations can be changed by editing the following file:
IDE_HOME\bin\idea.properties
Follow the comments in idea.properties file to change the defaults,
make sure to un-comment the lines defining these properties:
idea.config.path
idea.system.path
idea.plugins.path
idea.log.path
On the other hand you can change the location of your project to D:/Users/David. you should also have a look inside the project folder, there should be a .idea folder with has a library directory. They contains the location of the libs used in the project with their paths.
As dawez allready answered, you should edit idea.properties to set config, system, plugins and log paths.
But if you want to change the user.home path, then you must edit idea.exe.vmoptions file. Just add the following at the end of the file:
-Duser.home=your_new_user_home_path
If you use idea64.exe then you should edit idea64.exe.vmoptions file.
JetBrains had added complete set of features to support such a case and this is described here:
Changing IDE default directories used for config, plugins, and caches storage

Is there a "Rails Way" include a jQuery plugin in the Asset Pipeline?

Many jQuery plugins have the following directory structures:
/<plugin name>
../css
../images
../js
The CSS files usually have relative links to the images in them. What I want to do is include these plugins in the Rails Way under the Asset Pipeline, and hopefully that doesn't involve having to renamed the file references to remove the relative links. Is there such a Rails Way?
Could it also be that it's overkill to include an already-minified jQuery plugin in the Asset Pipeline?
You should try to add your assets to the load path which is the recommended way, as far as I know. If the application you're running has the assets-pipeline activated, it should find your assets after expanding the path in your application.rb
config.assets.paths << Rails.root.join("plugins/plugin_name/assets/")
Not shure, if this is what you asked for but if not, you should check: http://guides.rubyonrails.org/asset_pipeline.html#asset-organization
Remeber to restart your server
I had the same issue and also tried to find "the Rails way" to do this. And this is what I ended up with at the end of the day:
As Rob already mentioned:
vendor/assets is for assets that are owned by outside entities, such as code for JavaScript plugins and CSS frameworks.
Source: 2.1 Asset Organization
Lets take a practical example: using the jquery_datepicker gem (Note: we had to use a workaround because of this issue: bundle pack does not work with git sources).
1) Installing the gem (pretty straighforward):
cd vendor/gems
git clone https://github.com/albertopq/jquery_datepicker.git
2) Add this to your Gemfile
gem 'jquery_datepicker', :path => 'vendor/gems/jquery_datepicker'
3) Install a jquery-ui theme
From ThemeRoller select a theme, check Datepicker and Slider
and the jQUery version
Download and extract the content of the package
CSS/images from the css/theme-name folder move them:
jquery-ui-1.8.xx.custom.css to app/vendor/stylesheets/
the images folder to app/vendor/images/ (yes, move the entire folder images so you end up with something like this app/vendor/images/images/ui-icons_256x240.png
i18n from the development-bundle/ui/i18n folder (optional) move them to:
Create a folder i18n under app/vendor/javascripts/
move jquery.ui.datepicker-xx.js to this folder app/vendor/javascripts/i18n/
make sure the i18n folder is loaded so include in application.js
//= require_directory ./i18n
vendor/assets is loaded automatically AFAIK so you don't have to include the path in the asset pipeline.
I'd like to see how others are approaching this, it's a very good question.
I think the reason you haven't received an answer is because it's kind of unclear what you're asking. Are you asking if it's overkill to put your plugins in the asset pipeline? Are you asking if you have to rename file references?
I always put all my jquery plugins in my asset pipeline. Overkill or not, there all in one place and they only get compiled once so even if compiling them takes longer, it doesn't affect my app.

How to install play! framework modules?

I'm trying to install this pagination module for my Play! application, but can't get it to work. I've extracted the zip file inside /play/modules/paginate-head/ and I an example here on SO, to change my dependencies.yml file into:
# Application dependencies
require:
- play
- pagination -> paginate-head
repositories:
- My modules:
type: local
artifact: ${application.path}/../[module]
contains:
- paginate-head
But I still don't think the module is being loaded. I'm assuming it's documentation should appear on http://localhost:9000/#documentation/home or are there other ways to see if a module was loaded? It's not telling me anything in the console neither.
Any ideas how to get this installed?
You don't need to extract a zip file, just running the command
play install paginate-head
should work fine. But unzipping will also work. You also don't need that "repositories" section in your dependencies.yml file. Play! knows where to find modules.
The real issue is that your require should look like this:
require:
- play
- play -> paginate head
Notice play to the left of the '->' which signifies that it's a module. Also no dash between 'paginate' and 'head'. That's because 'paginate' is the module name and 'head' is the version and these should be separated by a space.
Also, for modules that are hosted in the main Play! modules repo, you don't even have to install them. You can just add the require above and start Play! and it will install it automatically. Though it will install under the applications modules directory, not the play modules directory.
Hope that helps!

rails 3 sass compiling

Hello I have one question I have my file main.scss which is in public/stylesheets/scss. In documentation is written:
By default, .sass and .scss files are
placed in public/stylesheets/sass
(this can be customized with the
:template_location option). Then,
whenever necessary, they’re compiled
into corresponding CSS files in
public/stylesheets. For instance,
public/stylesheets/sass/main.scss
would be compiled to
public/stylesheets/main.css.
I have in my gemfile gem 'haml'
And from my view I do sth like this
= stylesheet_link_tag 'main'
And the file is not found when I check the source(there is a file with with information about routing error). I guess that compiling it by hand it is not way to go so how I can make compile scss file to public/stylesheets automatic? What mean in documentation that they are compiled when necessary?
Thanks in advance
Put your .sass or .scss files in public/stylesheets/sass, not public/stylesheets/scss. Then the stylesheets should automatically generate whenever you change the corresponding sass/scss file. The generated stylesheets end up in public/stylesheets/.
Renaming the folder should make it all work.
EDIT: it looks like Rails 3.1 is going to be not only including SASS by default, but it will also be moving most of the stuff found in the public folder to the app folder... so this answer will only apply to versions of rails before 3.1.