Rails Missing Template On Production Server - ruby-on-rails-3

Before I start, I'd like to stress that I've looked for answers and I've tried to solve the issues by myself.
I have 2 types of controllers -
A controller with a set of methods that render JSON - works perfectly
A controller that actually renders HTML
This code is working perfectly on my local machine and the problem that I have with the second controller is on my production machine.
I've added 755 permissions to all my files but my file owner is the only user on my server which is "root". I've added the files to the www-data group though.
My controller is simple.
class AdministratorController < ApplicationController
def login
end
end
And my file is views/administrator/login.html.haml.
I'm getting an error -
ActionView::MissingTemplate (Missing template administrator/login, application/login with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder]}. Searched in:
* "/var/www/sitename/app/views"
):

Try to add to your Gemfile
gem 'haml-rails'
And run bundle install.

The issue has been resolved. I'm not sure what exactly went wrong with the template but I began seeing a different error relating to compiled assets. I just recompiled the assets and restarted the server. Thanks for all your help!

Related

Prestashop Productcomments Module Issue

I am experiencing a problem with the Productcomments module which I am using in a custom module and I cannot figure out how to fix it. The problem is with the star rating in the Productcomments form itself. This form works perfectly in a localhost environment - see images 1 and 2, but not on a live server - see images 3 and 4. On the live server it is showing no stars, just radio buttons, and no delete button for removing the stars.
Form as it looks on WAMP
Code from Chromes Inspect for WAMP
Form as it looks on Live Server
Code from Chromes Inspect for Live Server
Disabling the link to the following 2 js files recreates the problem on the local server which would suggest that the problem lies in the links to these two files on the live server, however I have checked all links to these files and they are correct, as are the permissions for these files.
jquery.rating.pack.js and productcomments.js
Occasionally when I clear cache under Advanced Parameters > Performance I get the following error message:
Fatal error: Uncaught --> Smarty: unable to write file /home/productm/public_html/cache/smarty/compile/10/e2/20/wrt5cbbb0747109d3_91450142
<-- thrown in /home/productm/public_html/tools/smarty/sysplugins/smarty_internal_write_file.php on line 46
This problem applies to all 1.6 versions of Prestashop tested.
Any suggestions on how to fix this problem would be appreciated.
Thanks
Kathleen
The error code you've got from clearing cache is linked to permission problems.
Here's probably a duplicate of your issue: How to fix erorr "Fatal error: Uncaught --> Smarty: unable to write file"?
Check that your prestashop files are set to 644 and folders 755 permission. (not just the js files you've mentioned).
Also if you manually moved the module to your live server(ftp), check the ownership of those files.
Edit:
I'll add this to the answer since the permissions didn't fix your problem.
looks like you have a prestashop bug going on with the JS (Synchronous loaded scripts)
here's a patch to fix that, maybe it fixes your original problem.
https://github.com/PrestaShop/PrestaShop/pull/6749/commits/73fd8dbed9f413a70f7d04fc4badd48f00ca501a

Error message: NameError at /users/sign_in undefined local variable or method `require_no_authentication' for #<SessionsController:0x########>

I'm working on a RoR app with Devise. When I came in to work today and tried to start up my local dev environment, RoR failed when I tried to go to the sign in page:
NameError at /users/sign_in
undefined local variable or method `require_no_authentication' for #<SessionsController:0x########>
It looks like the error is not being raised within the code we wrote, but instead from deep within the Devise gem. I'm guessing that somehow, my dev machine isn't configured right.
Here are some things I've tried to fix the bug:
I ran rake db:migrate and rake db:terraform.
I ran bundle install.
I ran rvm gemset empty and bundle install to reinstall all of my gems.
None of these worked.
In addition, here are a couple more strange things about this error:
None of the other devs at my workplace are having the same error, even though they're on the same codebase.
After trying to figure out the error for a while, I switched to a branch that I haven't updated since before I started getting this bug. Even though it was working before the weekend, that branch now fails with the same error.
Does anybody know anything I could do to try to fix this error? Does it sound like some part of my local configuration is incorrectly set up?
In my project, I had added a file in app/controllers called devise_controller.rb. It looked like this:
class DeviseController < ApplicationController
# Asks Devise how much time is left until the current user is
# automatically logged out, without resetting the logout timer.
def time_until_logout
raise "let's inspect here"
end
end
When I deleted this file, the bug went away.
I filed a bug report about how adding a DeviseController caused RoR/Devise to blow up on Devise's repository: https://github.com/plataformatec/devise/issues/2520

no such file to load -- map_by_method

This question was asked before here, but can't say that the answer helps me. I am using Rails 3.1.3. When I run rails console on my local dev machine, I get the following message:
no such file to load -- map_by_method
The message doesn't prevent the irb session from launching, so it's benign. But I'd like to get rid of it. At one point in time I had the map_by_method gem installed, but I removed it from the Gemfile and gemset -- yet the message still appears. Any idea how to vanquish it?
there might be some causes for this:
there might be some other gem which has it as a dependency
you might have a require 'map_by_method' in your code
you might have a require in your .irbrc
the .irbrc can be located in your user home or in the current working directory.
have a look at an example .irbrc here: http://matthewhutchinson.net/2010/9/19/rails-3-bash-aliases-and-irbrc-configs
Probably the gem map_by_method has done some permanent changes on your system. Try re-installing it. It should fixed your problem. Same thing happened to me once. If it doesn't, try specifying it in development section of gemfile.

Heroku + Haml Problems

I am having issues with Heroku and Haml, I am able to run my app on localhost no problems, all test pass to, however when I go to run it on Heroku I get the following error:
We're sorry, but something went wrong.
We've been notified about this issue and we'll take a look at it shortly.
I read another post on Stackoeverflow that basically said to add a .gems file and add:
haml --version '>= 2.2.0'
I did that and I'm still having the same problem, so I'm wondering what I am doing wrong.
Update: I fixed that problem had to do with cache - and Heroku being read-only however now the theme I've selected via web-app does not load up on the Heroku page it shows up on local host however correctly. I looked at the log file for Heroku and it doesn't show any errors, so is it another permission issue?
Here is the log file - https://gist.github.com/1173667
Thanks,
Looks like your stylesheets are not included as part of the layout.
Assuming your stylesheet is available as public/stylesheets/styles.css, try adding the following line inside the head tag in application.html.haml
= stylesheet_link_tag 'styles.css'
That should resolve the theming issue. If not, post the code in application.html.haml
UPDATE:
From the logs, looks like you have two layouts: layouts/sign and layout/application. If they are there for a reason, you need to address that.
Else, change your home controller to render the new layout:
class HomeController < ApplicationController
layout "sign"
end

Multiple public folders, single rails installation

I have a rails application I would like to use for multiple sites, each with different designs.
I would like to change the rails installation /public directory to something else (dynamically eventually). However, I have run into a problem (bug?) changing directories...
In my application.rb file I change the paths.public path to something other than "public" (let's say "site_one"). Here is the code:
puts paths.public.paths
paths.public = "site_one"
puts paths.public.paths
The two "puts" commands are for debugging. Now run "rails s" and you will see:
/home/macklin/app/public
/home/macklin/app/site_one
This verifies the path is changed correctly. However, shortly afterward, rails throws the following error (let me know if you need the full trace):
Exiting
/usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/paths.rb:16:in `method_missing': undefined method `javascripts' for #<Rails::Paths::Path:0x7f422bd76f58> (NoMethodError) from /usr/lib/ruby/gems/1.8/gems/actionpack-3.0.3/lib/action_controller/railtie.rb:47
My guess is it cannot find the javascripts directory even though it is clearly sitting in the "site_one" folder.
Does anyone know why I am getting this?
I know this question is pretty old, but I think I found an answer for this in Rails 4.2.
You just simply have to put this line in your config/application.rb:
middleware.use ::ActionDispatch::Static, "#{Rails.root}/another_public_folder_name", index: 'index', headers: config.static_cache_control
This makes all files in /another_public_folder_name to be served by Rails.
This is the way Rails use to setup the standard /public folder. I found it checking the sources:
https://github.com/rails/rails/blob/52ce6ece8c8f74064bb64e0a0b1ddd83092718e1/railties/lib/rails/application/default_middleware_stack.rb#L24
Duh. Just add 2 more rules for stylesheets and javascripts (I guess they get wiped when you change the parent path)
paths.public.stylesheets = "site_one/stylesheets"
paths.public.javascripts = "site_one/javascripts"