I am using Solidus for the first time. I have been able to have it working as required. However, I am trying to make changes to the frontend. Although I'd rather use bootstrap 4, I could only find a way to port it with bootstrap 3 using a gem as described here.
I have followed the instruction as explained on the page. However when I make the test changes described, expecting to see the same changes, nothing happens. In fact the page is no longer structured as it was initially which I suppose is due to overwriting all.css used by spree on the app.
I am not sure why things are not working. I tried to undo changes by running rails destroy solidus_bootstrap_frontend:install but this doesn't restore the changes. Any help would be appreciated.
Thanks.
run
rails solidus_bootstrap_frontend:install
It'll tell you what files it tries to create, and will probably ask if you want to overwrite them.
Delete these files and you'll reset the appearance to how it was before you ran the command
Related
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
I initially created it in rails 5 with the --api tag.
From http://edgeguides.rubyonrails.org/api_app.html,
I removed config.api_only = true
I changed
class ApplicationController < ActionController::API
end
to
class ApplicationController < ActionController::Base
end
The problem I'm having now is when the view is getting rendered, ex. welcome/index.html.erb, the corresponding CSS file assets/stylesheets/welcome.css.scss is not.
Any idea how I can fix this, or more generally convert the API application to a full app?
Thanks!
I ran into this same problem and I believe I've solved it. I was hoping to find a simple rails generator to convert it, but unless I've missed something it's not that easy. However, rails does make it easier than doing it totally manually.
The key is that the rails new command can be used on an existing app. Note that this answer assumes you know how to use git and are using it on the existing app.
First and most importantly, make a new branch. This serves two functions, 1) so you shouldn't lose your work if you mess it up (although it still might be a good time to back it up, like to GitHub), and 2) so you can compare the files that have conflicts after this process and retrieve any work that this process overwrites (it wasn't much for me, but it was important).
In the terminal, from the directory of the app you want to change from API only to standard. Run the following commands to go up one directory and then have rails write a new project over your existing one. Use the same options on the second command that you used when creating your app initially. For example, for me I replaced [options] below with -d postgresql --skip-turbolinks --skip-spring -T because those are the options I used when creating my app. I'm using the --skip-bundle flag because it might change your Gemfile more than you want it too and you'll probably want to change some of it back before bundling.
$ cd ..
$ rails new your_app_name --skip-bundle [options]
Now rails is going to go through it's usual process of creating all the files for a new app, but this time it's going to skip almost all of them because they're already there. It will stop on each one on which there is a conflict, and that's where you'll need to analyze the conflicts one-by-one.
Here's what worked for me on the conflicted files:
Submit d on each one of them to see the differences.
If the difference is only adding lines, then allow it with Y. That's why we're doing this after all.
If the difference is only removing code, then reject it with n.
If the difference is both adding and removing code, write down that file to come back to after this process. Then accept it with Y.
After this is finished, use git to examine the difference on each file from (4) that you wrote down. You'll want to keep the changes that rails added, but then you'll likely want to copy all the code that it removed back in. This will probably include the Gemfile.
One notable difference is that rails changes the application controller from inheriting from ActionController::API to ActionController::Base. I want one controller for each, so I created a new file `app/controllers/api_controller.rb'. Then I copied what was in my original ApplicationController over to the new file and just changed the class name to ApiController. Then I changed all my existing API controllers to inherit from the new ApiController instead of from ApplicationController.
After that is done, then run bundle install to install the gems rails added into the app.
That worked for me. I hope it helps. Good luck!
From a directory outside of the api application (such as its parent - cd ..) I would do
rails new comparison_real_app
and then compare the contents of the comparison_real_app with your app and copy over the files that are missing into the api app and change any other files as required.
So there's probably more things that will need to be done as I (you) go along, but to resolve the issue with stylesheets you need to manually create your views/layouts/application.html.erb and assets/stylesheets/application.css files.
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.
I have been eating my nails the whole weekend to figure out the right combination of modifications to the official refinerycms-calendar in order to make it work with RefineryCMS 2.1.1.
Here are my conclusions and efforts, hoping that someone will drive me to the right direction:
Adding just gem 'refinerycms-calendar', '~>2.0.0'
as suggested in the github page is not working out of the box. You need to correct the dependencies on the .gemspec file. There are many forks out there created only for this correction.
So, I forked the refinery/refinerycms-calendar project, corrected the dependencies and used my fork in the Gemfile.
Backend (BE) works fine: Created an event, went back to FrontEnd (FE), got a "This page is NOT live for viewing"
This frontend (FE) inconcistency is corrected to the BE > Pages > Venues page: /calendar/venues is not an existing route and needs to be corrected to /calendar/events. The seeds.rb needs to be corrected for a permanent solution.
Go back to FE, now the /calendar/events is blank! I only get the title of the Page as defined on the relative Pages page.
A look on the rails server log reveals that there is a :find_page error resulting form the fact that the refinerycms-events.css under the engine's public/stylesheets folder is neither picked up nor referenced correctly inside show.hrml.erb and index.html.erb files. I copied the refinerycms-events.css under vendor/stylesheets and changed the reference to refinerycms-events.css accordingly.
Refreshed FE but still there is a blank page both when getting /calendar/events and /calendar/events/#{event}
NOTE: If I "rake routes" I can see that the routes for the FE portion are repeated 3 times. I am not quite sure for this behavior, but when I substituted "Refinery::Core::Engine.routes.append do".gsub("append","draw"), I could only see them once.
I have tried many forks around and all of those seem to demonstrate the same behavior.
Can anybody please let me know:
a. If you finally managed to have this (official refinery release) engine fully functional in your projects and if yes which branch was used and with which exact Refinerycms and refinerycms-calendar version combination.
b. If used used a fork rather than the official refinerycms-calendar release, then which fork/branch is that.
I hope someone to have that nailed down.
Best regards,
Petros
Well, seems that changing :body_content_left and :body_content_right with :body and :side_body respectively inside the Engine's show and index views, solves the issue of the /calendar/events and /calendar/events/:event FE pages being blank.
I am still unsure why this is causing such an issue and it is kind of weird nobody to have reported it until now.
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.