Issue with Rails Generator Building a Plugin - ruby-on-rails

I am building a Rails plugin for an application at work.
I want to extract logic that was used in multiple locations, but implemented slightly differently, and add new features needed without doing it 2-3 times over.
I've never build a gem, but according to what I was reading it is possible to use rails generate.
However this has not been the case for me.
Running rails g model Something stuff:type:
First interesting thing is that it is generating mini test stuff when I explicitly told the plugin not to use mini test (using Rspec).
Then looking in my folder structure for the plugin, no db/ folder, nothing added to app/models/, and no test/ folder:
Running the command a second time reveals to me that the files are indeed created:
My questions are:
Where is this stuff going? Can I even find out?
Has anyone encountered something similar? Is it due to a misconfiguration, or bug? Essentially, what's happening?
I would truly appreciate any advice or suggestions!
EDIT #1
Forgot to mention that I checked within the spec/dummy application in case things were being created there, and it is still empty as I left it.
EDIT #2
So I found where the files were by using the find command:
And yeah it added the files to my home folder...
At least now I can just paste them in the right location, but obviously this is bizarre and I'd like to get this resolved, figure out what is going on.

Okay so turns out that yes you may use Rails Generators when building a gem. Also, the generated files will not be placed inside the dummy application unless you are in that directory.
Everything is working as expected on a different computer.

That stuff is going into dummy app that is usually located in test/dummy. In your case, it seems to be located in specs/dummy.
Yeap and nope. That's not misconfiguration.

Related

Rails 5 Upgrade: routes.rb file cleared out

I am upgrading a Rails app from 4.2.x to 5.0.x. After I updated all my Rails-related gems in Gemfile, I ran the rails task for updating all my files to conform to the newest version, as per the upgrade guide:
rails app:update
There were many conflicts in this command, so I pressed a to accept all conflicts and then review them manually before committing them. My main concern is what happened to the config/routes.rb file. Basically, the entire contents of the file, save for the Rails.application.routes.draw block and a single comment about the DSL added to the end of the file, were kept. All routes that have been added to the app over the years were cleared out, not to be found in any other file.
This issue doesn't block me, I'll simply checkout the file to bring it back to its former state. However, what especially concerns me is that an essential file was cleared out in what appears to be a normal situation for upgrading a Rails version. I'd like to see if anyone else has run into this issue, whether this is expected, what's going on. Comments from Rails maintainers are welcome. Thank you.
The app:update task is just a slightly modified version of the task that creates a new Rails application. It writes out files under config/ and bin/ based on the templates from the new Rails version. If you selected a to accept all conflicts, then that simply means that Rails is going to overwrite any differing files with its own copy without asking you. This is normal and expected. If you don't want that behavior, then don't press a.
config/routes.rb is almost certainly the one file under config/ that will differ almost completely from the empty boilerplate file.
Realistically, Rails can't be expected to parse your custom changes and merge them with a new template.
For what it's worth, I like to start out doing exactly what you did, with a clean working directory just let the app:update task overwrite anything it wants to, and then go through all the changes with a side-by-side, SCM-aware diff tool like vim-fugitive to stage or discard the differences.
Well, just don't accept all conflicts, take a look in each one of it. Making version upgrades of 1 level of magnitude may change a lot of things and the process takes a while.
First take a look on the changes in the framework and do the process carefully. You may be breaking a lot more stuff that you are not noticing:
http://edgeguides.rubyonrails.org/upgrading_ruby_on_rails.html#upgrading-from-rails-4-2-to-rails-5-0

Models not reloading in development in Rails (3.2.11) project

I've searched fairly extensively for any advice and have yet to find it so, here goes:
My Rails project fails to automatically reload models in development. Reloading them currently requires a full server restart.
Previous instances of this issue have been related to non-activerecord files placed in the models directory, though this is not the case for me.
config.cache_classes is properly set to false in my development config file. Views and controllers reload without issue.
All of my rails components are version 3.2.11. I have tried disabling all of my development-specific gems to no avail. This is obviously not a productivity stopper, but it is quite an annoyance. Any help appreciated and I am happy to provide more information if it would help, though I am not using any exotic gems.
Thanks!
Some possibilities:
You are not really running on developement environment
You are changing a model within a namespace and didn't told rails to autoload the path
You are changing a file that is included in your class, not your class directly (or any of the many variants for this)
You are caching classes
Considerations:
Things might change according to the webserver you are using
How do you know it's not reloading?
I ask my question because I was having the exact same issue when I was trying to insert a debugger into what I thought was a piece of code that was being executed. I assumed the model wasn't being reloaded since it was not hitting the debugger but it was actually a call back that was redirecting me around the code with the debugger line in it.
So, it might be something other than your models not being reloaded.

ruby on rails unable to find interface that appears to be proplery defined

I'm brand new to ruby on rails and trying to run an application developed by others. I downloaded it from SVN it running yesterday, but today when I try to run it the first attempt to access the site's home page I get the message:
expected .../app/helpers/interface/table_helper.rb to define Interface::tableHelper.
.../lib/active_support/dependencies.rb:452:in 'load_missing_constant'
This file exists, and properly defines the tableHelper interface. Since I was able to run the program when I was setting it up yesterday, and others can run it without issue, I assume the problem I'm seeing is caused by an incorrectly set up environment rather then bad code somehow.
Can anyone suggest what I might try to figure out why rails can't seem to detect a properly defined interface?
If you were able to run the program once, perhaps something got screwed up? Have you made any changes to the code?
Alternatively, try stopping and restarting the server.
Also: what's the application? Maybe we can look at the codebase...

making a installer in rails

I have been working on this, very, small photo cms lately. And now i ready for setting it up to Github. So i will love to have some kind of installer, just as much for leaning it, I'm thinking something like you type a command and then it starts by copy all the files to the rails app, and then asking you for what your flickr_id is etc..
So i have to store all this information and call it down.. i.e if i should show some pictures, i have to use the flickr_id.
Hope you understood my question..
You can start by using rails-app-installer, it's not maintain completly but can works. It's use on the Typo project

why might rails-2.3.5 not reload some files under app in development mode?

I've added a subdirectory app/renderers after Railscast #101. The classes in that directory are not getting reloaded by my development server. It's driving me a little bonkers.
I've read everything I could find on forcing it to reload lib and/or plugins but this seems to be a different case since "everything under app should be reloaded automatically." Plus, I've checked ActiveSupport::Dependencies.load_once_paths, and app/renderers definitely isn't in it.
I'd also like to get the renderers to be automatically required, so that I don't have to go around putting require statements in the rest of my code. Is that sensible? How does it work for, say, models and other constants?
Doh. I should have been loading the files, not requiring them.
I'd still like to have them magically loaded -- not needing a specific load statement for each one -- but for now it's working :)

Resources