I have switched over to pow in order to use ssl in development and I want to switch the host configuration in development, however devise continues to send email prefixed with the localhost:3000 domain. Here is what I have in my config/environments/development.rb file:
config.action_mailer.default_url_options = { :host => 'want_freight.dev' }
I have restarted my server and I have grepped my entire application looking for the offending use of localhost:3000 however my search turned up nothing outside of tmp and log files. Does anyone know why this would not be working??
I changed config.action_mailer.default_url_options to point to Pow's .dev URL, restarted my computer, and, against all odds, it was working again.
So I was able to have some success by adding :only_path => false to the default_url_options hash and using named urls, e.g. user_url( #user.id ) instead of link_to.
This problem was actually related to the devise_async gem causing conflicts with the mailer, I was able to resolve the issue by removing the gem from my gemfile.
No need to restart computer, just restart POW:
touch ~/.pow/restart.txt
Related
I have a problem using Cypress when running tests on our staging domain. For some reason Cypres browser opens the correct website but then immediately changes the url to the absolute domain and appends __/ at the end:
https://stagingdomain.com/administrators/login becomes https://stagingdomain.com/__/
On production this does not happen, the test passes correctly. Sidenote: Our staging environment is only accessible behind our corporate VPN, but besides that everything else is the same
it('Gets, types and asserts', function () {
cy.visit('https://stagingdomain.com/administrators/login');
cy.contains('ADMIN LOGIN');
cy.url().should('include', 'administrators');
});
});
I have followed all security measures provided on Cypress' documentation but none seem to be resolving this issue. Wondering if anyone else has faced the same challenge and has been able to overcome it
Turns out this was a known issue with Cypress which was since addressed in version 3.4.1
This is still any issue in 5.1.0.
I clearly have a page redirect to index.php which is in http://url.com/site/
Instead of redirecting to http://url.com/site/index.php like it should. The page is redirected to http://url.com/__/index.php which does not exist. It seems to be an issue with the doc root rewrite.
I also tried adding these to my cypress.json with no luck:
{
"baseUrl": "http://url.com/site/index.php",
"experimentalSourceRewriting": true
}
As a workaround, I simply redirect the user again and they check if the session is valid by getting to my secure page after my login.
I am new to rails. I am working on a sample application for social networking. I have managed to upload the profile picture of users manually (By copying the image uploaded to /tmp/image to the public folder- public/images/tmp/image) and saved the path to db as avatar_url.
In the profile view I used
<%= image_tag(#userinfo.avatar_url, :alt=>"Avatar image")%>
and getting the picture when running on the rails server.
But after that I have deployed the app in apache with passenger in the development environment by setting RailsEnv development. After that the images are not loading. I tried to go to myip:80/public/images/tmp/image, and it gives Routing Error.
After searching on the web, I found that adding config.serve_static_assets = true in production.rb will solve the problem in production. But no use for me because it also stated that the static files will serve in development by default. For confirming the problem again, I started the rails server and opened localhost:3000/profile, image is there and not getting the image in myip:80/profile.
So do I need to add any other config. Or am I not supposed to do that in this way.
Finally, I got the solution for my problem. Just sharing here.
The problem was actually because of permission issues. The picture will be created in a root temp directory on the form submission. Then I copied the image form the temp folder to the public folder. Hence it has only read permissions. After I deployed it, the image gets returns 403 forbidden error.
I used,
FileUtils.chmod 775, target
to set the permission. After that it worked well.
The option config.serve_static_assets = true tells rails to serve the static assets for your application, but that job should really be left to Apache.
Your issue sounds more related to your Apache configuration than rails.
I would take a look at a tutorial on how to configure Apache and Passenger to make sure your environment is setup correctly.
Anything in the public folder should be served by the web server. However myip:80/public/images/tmp/image is not a valid path. You would need to also have a filename at the end with an extension.
I'm using the ActiveAdmin gem in a Rails 4 app, and having trouble when it's deployed in production. It's working fine in development, or when I run it locally in production.
For example, after saving an Asset, instead of redirecting to https://domainname.com/admin/assets/1, it redirects to https://localhost/admin/assets/1, which doesn't exist, so it blows up.
As far as I can tell, I have things set up correctly. Here's my routes file:
Rails.application.routes.draw do
root to: redirect_to('/admin')
devise_for :admin_users, ActiveAdmin::Devise.config
ActiveAdmin.routes(self)
end
Things seem to work fine in production mode when I'm running it locally, but not when after it's been deployed behind SSL.
Has anyone else had trouble like this when using SSL with ActiveAdmin?
It turns out the nginx configuration was bad. Nothing to do with the Rails code at all!
I got the same localhost redirection problem on prod, but only with destroy method. I implemented a redirection that did the trick :
controller do
def destroy
super do |format|
redirect_to admin_model_path and return
end
end
end
I still don't know what was the root cause.
this is my first time posting to stackoverflow. I am learning Ruby on Rails and i want to ask the reason why my app doesn't redirect to the root i specified in my routes.rb.
I already deleted the public/index.html and also removed it from git.
Jba::Application.routes.draw do
get "home/index"
root :to => 'home#index'
end
Thanks for helping. :)
Make sure you clear the cache on your local browser in order to view the changes you've made to your code.
My client wants her entire app (all links) to run over HTTPS/SSL.
I put
config.force_ssl = true
in config/application.rb. However, now Safari and Firefox and Opera are all griping about app, with different errors.
(From Firefox, "ssl_error_rx_record_too_long")
Do I need a certificate? Or is there a simpler solution?
It turned out that I needed to do the following to make the entire Rails 3.2 app run over SSL:
1) In config/application.rb, instead of 'config.force_ssl', use the gem 'rack-ssl-enforcer', and
config.middleware.use Rack::SslEnforcer
2) Create a certificate using openssl/mod-ssl (CentOS)
3) Use "thin" instead of WEBrick - thin seems easier to configure for SSL.
Thin gets configured to use the certificate files generated in Step 2.