Google-Maps-For-Rails not showing map in Rails 3.1 - ruby-on-rails-3.1

I am trying to use the gem 'gmaps4rails'. I inserted all of the necessary code into my model and view, and I know that the geocoding is working. However, when I insert the code <%= gmaps4rails(#json) %> into my index.html.erb file, the map does not appear.
EDIT: I downgraded the version to 0.8.8, and I was able to run
rails g gmaps4rails:install to get the layouts. Does version 0.9.1 have a different command for installing the layouts?

I was having the same problem (couldn't get the generator installing) and getting the 404 for gmaps4rails.js.
The following steps worked (you had most of it).
I downgraded to 0.8.8;
ran the generator;
then copied the generated files from public/ to assets/;
changed back to version 0.9.1.
and it worked fine after that (i.e. map showing).

Related

Sass not compiling properly to application.css rails 7

I have setup a new rails 7 project with Bootstrap 5.2 and Sass, however when it comes to adding in custom styling (with Sass) Rails appears to not be compiling the Sass styling into app/assets/stylesheets/application.css. I have no errors to go off here and after spending far too long on the problem, decided to start fresh with the following setup instructions - https://railsbytes.com/public/templates/V2Gsg9
I had to remove the #import "bootstrap" code below as this throws a compilation error.
append_file 'app/assets/stylesheets/application.scss', <<-CODE
#import "bootstrap";
CODE
I'm unsure if this is relevant to the issue, however I was having issues with the bootstrap setup, where the JavaScript was not working, and followed the following setup from another stackoverflow https://stackoverflow.com/questions/70907799/bootstrap-5-javascript-functions-not-working-in-rails-7-app which has fixed this issue.
In summary, the only problem I'm now facing is that the css is not compiling. I found a number of other resources related to the same issue, however the setup is slightly different and when I try to run the solutions provided it does not work. I have seen multiple posts suggesting to attempt to run rails assets:precompile, which I did, however it broke all the styling setup and couldn't revert it back for some reason (part of the reason whey I started on a new project).
In addition to the new setup, I also tried this suggestion by "stevec" in the following https://stackoverflow.com/questions/71300845/custom-css-not-working-with-css-bundling-for-rails-7. This works, however it doesn't seem to be the Rails way of doing things. This suggests each stylesheet needs to be added to the app/assets/config/manifest.js and also to the application.html.erb file. To my understanding, each view should have its own style sheet which is then imported into application.css.
I feel I'm close to the solution but am finding it challenging at the moment to understand the documentation on the asset pipeline... Some recommendations suggest to install yarn/npm however I thought that's the benefit/job of importmap so have not gone down that path

Heroku production differing from local development (Rails)

I'm new to coding and to Rails and I've run into this issue for the first time - the local development version of my app is differing in a detrimental way from the production version.
I'm using Zurb Foundation on my Rails app and deploying to Heroku to see it in production.The issue that I am facing is that locally, the CSS I wrote to get the padding between the navbar and the rest of the page is working correctly, but when I deploy to Heroku the CSS is not rendering correctly and the padding is missing.
I wrapped the yield in application.html.erb with a div of a class I named "fixednavbar" and wrote the following css:
.fixednavbar {
padding-top: 60px;
}
I put this css in a layouts.css.scss file in the asset pipeline (Rails 3.2.13). The code in the application.html.erb file is as follows:
<div class="row fixednavbar">
<%= yield %>
</div>
I have checked the code locally and on github to make sure they match up and they do. I took a drastic step and started a new repository, then removed the local git repository and started a new one and pushed all the current files there (I created a new repository on github so that all of my previous versions are still in the original repository).
After doing this, I created a new Heroku app and deployed and still the production version is not rendering the CSS the same as the development version.
I'm at a complete loss as to why these versions would differ when the code is the same (unless there is something lurking somewhere else that I have not thought to check).
Any and all help is much appreciated. As I said, I'm knew to Rails (and coding for the most part) and this is the first time I've run into an issue like this.
Thank you!
Update:
I have continued to try to sort this out. I did other work on the application and then came back to this issue. I want to get the production version to reflect what is in development, so any help at all would be amazing.
To describe the issue further: It is almost as if my production deployment to Heroku is stuck in an old version of the app when the css wasn't worked out yet. The navbar color is stuck on the first color I changed it to and will not update to the new color. The sticky nav is still causing an issue in production where the body is partially hidden behind the nav.
Now, in development running the local server, I have fixed all these issues. The changes are reflected in development and everything is as it is intended to be.
After the changes, I commit to the git, then I push to github. After pushing to github, I push to Heroku.
The github files reflect the changes and the code is as it should be. Still, Heroku is not reflecting this.. I'm honestly stumped here and need some help please.
With some help from the users who responded, I was able to identify the error and search for the solution. I found it HERE.
The solution is to look in the production.rb file and find the line where it says
config.assets.compile = false
and change "false" to true.
config.assets.compile = true
Then run
rake assets:precompile RAILS_ENV='production'
After deploying to Heroku, you may need to run
heroku run rake db:migrate
This got everything working correctly upon deployment to Heroku.
How have you included this plugin? Instead of adding the js and css directly, try using their gem from https://github.com/zurb/foundation-rails and remove any direct references from your app. I've faced similar issues with other plugins like bootstrap, bxslider etc.
As a beginner, I was having a difficult time with the same issue. Because I'm using Rails 4, the simple step of removing this line from config/application.rb did the trick.
config.assets.initialize_on_precompile = false
https://devcenter.heroku.com/articles/rails-asset-pipeline
Granted, I troubleshot all the above steps and a few others from other postings.

Octopress - Generating blank files

Asked this on superuser.com, not sure if stackoverflow is a better suitable place for it, but I am not getting any answers yet:
===
I am trying to generate a new blog entry in my octopress setup, but I noticed that some previous posts are being generated as empty files in public, so are the new ones I am trying to generte.
There seems to be no difference at all between the markup files from one entry which is being properly generated to another that isn't
I've got two octopress installations, one's working and this one I am talking about isn't, updates octopress on both, reinstalled bundle but no luck, files as atom.xml are also not being generated correctly.
Also updated from ruby 1.9.2p290 to latest release from 1.9.3 but also did not difference.
Anyone's encountered this before?
===
This is most likely because you started using codeblocks. This was happening to me, and even posts/pages that didn't use codeblocks would fail to generate. My problem (on Windows) was that I didn't even have Python installed (thought I did). Installing it fixed the problem, then gave me another error, which was fixed by updating the pygments.rb (note .rb) gem. Doing these two things fixed all my problems.
There's a similar issue if you're on arch linux which defaults python to version 3 which isn't supported by pygments.rb yet. You'll have to look around to figure out how to fix that to use 2.7 instead, but it should be pretty straightforward.
Can you provide an example of: a) a post that doesn't generate correctly, and b) a post that does generate correctly?
I assume they are just individual posts (and not, for example, pages like /about/). I would also assume that they render as blank both in the blog index on your front page and on the individual post page.
Also - what does render? Is it rendering the rest of the page, but just without the "content" of the post itself? Or does the page not even exist? (404?)

Jekyll page failing on github but works successfully locally with --safe flag

I have a Jekyll based post which works successfully when running locally with the --safe flag on. However, the page build fails on github pages. I am not using any plugins either. Can someone please help me figure out what is not compatible with github? Their page is not very helpful. I'm already following their advice of not plugins and using --safe locally to test before committing.
Link to my post: https://raw.github.com/danishm/danishm.github.com/master/_posts/2012-07-23-maintaning-read-more-links-when-moving-from-drupal-to-jekyll.md
Could it be the usage of {% raw %}? or the fact that I am trying to talk about liquid template code itself and trying to syntax highlight it
The issue is due to the fact that github pages uses liquid 2.2.2 and my local install was using liquig 2.3.0. The filter {% raw %} is new in 2.3 and not available in 2.2.2. In version 2.2.2, you need to use {% literal %} instead.
Once I made that change, the page got built successfully on github pages and is now visible on my blog.
I was also able to reproduce the issue locally by installing Jekyll 0.11.0 and liquid 2.2.2, which is what github pages use.
Not sure, but there might be something wrong on GitHub, their status page shows that there was some problems with Pages (25th Jul 2012), that should be fixed now, but I still have same issues as you, pages won't compile, and local run w/ jekyll --pygments --safe works fine.
If you had used Jekyll version 1.0 at the beginning, you may config 'auto' option in _config.yml file. But the current version of Jekyll is 1.2.x, so this option is depreciated. In my case, it made my errors: successfully in local but not working in git page. The solution is so easy, just comment this line: "auto:true". Everything seems OK. In more details, you must comment that line to turn on Auto-regeneration feature which allow the server regenerate html pages automatically.

Twitter Bootstrap 2 breaks Rails 3.1 page scripts?

In attempting to upgrade to Bootstrap 2 (using twitter-bootstrap-rails gem), it seems that page-specific scripts are rendered unusable: all scripts must be loaded from the Asset Pipeline to work. Even a simple $ alert function called from a page script tag doesn't appear to load, even if yielded into the head after the AP loads. The original Bootstrap played fine with page scripts.
I understand that scripts should usually be loaded through the AP as a practice, but has anyone else experienced this behavior, and is this something that can be remedied easily, or is this something unique to my setup? (Rails 3.1.3, rvm, ruby 1.9.3, xCode 4.1)
A git reset solved the issue, but I'd rather upgrade and use the new TB features....
Thanks for any insights or thoughts about how to track down the issue.
You are using rails 3.1.3 the new gem works fine for me on rails 3.2.2 so it should be that your jquery-rails gem might not be using the latest jquery. so try upgrading cos the new gem works with the latest version of jquery

Resources