Yesod: how do you interpolate a route with a path piece? - path

If I have a route such as
/foo/#String FooR GET POST
How do I interpolate this path in a hamlet file (say, to post to?)
The following don't work:
<form method=post action=#{FooR} ... >
<form method=post action=#{FooR}someString ... >
<form method=post action=#{FooR}#someString ... >
<form method=post action=#{FooR}#{some_variable} ... >
Thank you!
EDIT: Got it. It's
<form method=post action=#{FooR some_variable} ... >

Related

Heroku Twitter api app deployment with Rails

I am new to Ruby and Rails in general and am following this series
https://gorails.com/episodes/rails-for-beginners-part-38-deploying-to-heroku
I have this weird issue where is everything seems to work fine except connecting my app with
Twitter Api.
I did everything to connect successfully but nothing seems working!
I added the website link to Twitter developer callbacks urls which are
https://jadwlh.herokuapp.com/
along with
https://jadwlh.herokuapp.com/auth/twitter/callback
I added both
API_KEY
and
API_SECRET
to Config Vars.
I even changed SECRET_KEY_BASE in Config Vars
to the one provided in the credentials file in my app!
Even though tried everything, still got this message shown in the image below when I try to
connect my app with Twitter Api
routes.rb file
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
Rails.application.routes.draw do
#GET /about
get "about", to: "about#index"
get "password", to: "passwords#edit", as: :edit_password
patch "password", to: "passwords#update"
get "sign_up", to: "registrations#new"
post "sign_up", to: "registrations#create"
delete "logout", to: "sessions#destroy"
get "sign_in", to: "sessions#new"
post "sign_in", to: "sessions#create"
get "password/reset", to: "password_resets#new"
post "password/reset", to: "password_resets#create"
get "password/reset/edit", to: "password_resets#edit"
patch "password/reset/edit", to: "password_resets#update"
get "/auth/twitter/callback", to: "omniauth_callbacks#twitter"
resources :twitter_accounts
resources :tweets
# get "/", to: "main#index"
root to: "main#index"
end
Application logs
2021-05-31T06:15:04.415968+00:00 app[web.1]: [13f44544-8fd2-4348-8b08-1191ad53716b]
2021-05-31T06:15:04.418156+00:00 heroku[router]: at=info method=HEAD path="/auth/failure?message=session_expired&strategy=twitter" host=jadwlh.herokuapp.com request_id=13f44544-8fd2-4348-8b08-1191ad53716b fwd="217.182.175.162" dyno=web.1 connect=0ms service=3ms status=404 bytes=180 protocol=https
2021-05-31T06:15:31.243002+00:00 app[web.1]: I, [2021-05-31T06:15:31.242901 #4] INFO -- : [c5f8ff8c-58fa-439d-a9f3-e08047bc5aa8] Started POST "/auth/twitter" for 46.152.103.96 at 2021-05-31 06:15:31 +0000
2021-05-31T06:15:31.243645+00:00 app[web.1]: D, [2021-05-31T06:15:31.243583 #4] DEBUG -- omniauth: (twitter) Request phase initiated.
2021-05-31T06:15:31.388564+00:00 app[web.1]: E, [2021-05-31T06:15:31.388453 #4] ERROR -- omniauth: (twitter) Authentication failure! 400 Bad Request: OAuth::Unauthorized, 400 Bad Request
2021-05-31T06:15:31.390962+00:00 heroku[router]: at=info method=POST path="/auth/twitter" host=jadwlh.herokuapp.com request_id=c5f8ff8c-58fa-439d-a9f3-e08047bc5aa8 fwd="46.152.103.96" dyno=web.1 connect=1ms service=150ms status=302 bytes=834 protocol=https
2021-05-31T06:15:31.574904+00:00 heroku[router]: at=info method=GET path="/auth/failure?message=400+Bad+Request&strategy=twitter" host=jadwlh.herokuapp.com request_id=3adfd6f0-58b9-47c3-ab04-017161a56e18 fwd="46.152.103.96" dyno=web.1 connect=1ms service=6ms status=404 bytes=1902 protocol=https
2021-05-31T06:15:31.571195+00:00 app[web.1]: I, [2021-05-31T06:15:31.571067 #4] INFO -- : [3adfd6f0-58b9-47c3-ab04-017161a56e18] Started GET "/auth/failure?message=400+Bad+Request&strategy=twitter" for 46.152.103.96 at 2021-05-31 06:15:31 +0000
2021-05-31T06:15:31.572790+00:00 app[web.1]: F, [2021-05-31T06:15:31.572717 #4] FATAL -- : [3adfd6f0-58b9-47c3-ab04-017161a56e18]
2021-05-31T06:15:31.572791+00:00 app[web.1]: [3adfd6f0-58b9-47c3-ab04-017161a56e18] ActionController::RoutingError (No route matches [GET] "/auth/failure"):
2021-05-31T06:15:31.572792+00:00 app[web.1]: [3adfd6f0-58b9-47c3-ab04-017161a56e18]
Thank you: )
I found the solution.
It just was copying master.key and replace it as it says below!
heroku config:set RAILS_MASTER_KEY="copy and paste here config/master.key "
How to get rails master.key after upgrading to rails 5.2

Heroku not working and I don't know where to start

I apologize for this being a vague question but I don't know what is going wrong so I don't know how to ask the questions.
I set up a rails app and it's working locally. However, when creating it on Heroku Create and it gets set up on my Heroku server it does not work. When I run Heroku open I get this page:
https://polar-taiga-65467.herokuapp.com/
I can post logs or anything else to help. If someone can help me figure out what to do from here it would be appreciated.
Here is my GitHub project: https://github.com/TomTom319/morali-tee
Here is the log from Heroku:
2018-01-16T05:13:18.292500+00:00 app[web.1]: I,
[2018-01-16T05:13:18.292411 #4] INFO -- :
[99bf3dd0-59b3-4438-a3f7-36a037174b55] Rendering simple_pages/index.html.erb within layouts/application
2018-01-16T05:13:18.295106+00:00 app[web.1]:
[99bf3dd0-59b3-4438-a3f7-36a037174b55] 3: 2018-01-16T05:13:18.293930+00:00 app[web.1]: I,
[2018-01-16T05:13:18.293863 #4] INFO -- :
[99bf3dd0-59b3-4438-a3f7-36a037174b55] Rendered simple_pages/index.html.erb within layouts/application (1.3ms)
2018-01-16T05:13:18.294179+00:00 app[web.1]: I,
[2018-01-16T05:13:18.294089 #4] INFO -- :
[99bf3dd0-59b3-4438-a3f7-36a037174b55] Completed 500 Internal Server Error in 15ms 2018-01-16T05:13:18.294881+00:00 app[web.1]: F,
[2018-01-16T05:13:18.294798 #4] FATAL -- :
[99bf3dd0-59b3-4438-a3f7-36a037174b55] 2018-01-16T05:13:18.295107+00:00 app[web.1]:
[99bf3dd0-59b3-4438-a3f7-36a037174b55] 4: <%= image_tag("yellowtee", class: "img-responsive first-tee")%>
2018-01-16T05:13:18.295101+00:00 app[web.1]: F,
[2018-01-16T05:13:18.295028 #4] FATAL -- :
[99bf3dd0-59b3-4438-a3f7-36a037174b55] 1: <h1 style="color:red;">MoraliTee</h1> 2018-01-16T05:13:18.295104+00:00
app[web.1]: [99bf3dd0-59b3-4438-a3f7-36a037174b55] 2: <p>Welcome! We are on a mission to give back to people around the world</p>
2018-01-16T05:13:18.295158+00:00 app[web.1]: F,
[2018-01-16T05:13:18.295086 #4] FATAL -- :
[99bf3dd0-59b3-4438-a3f7-36a037174b55] 2018-01-16T05:13:18.760114+00:00 heroku[router]: at=info method=GET
path="/favicon.ico" host=polar-taiga-65467.herokuapp.com
request_id=6a2ec4b7-7054-46b7-b76a-28ef5ab3f69a fwd="24.15.217.85"
dyno=web.1 connect=0ms service=2ms status=200 bytes=143 protocol=https
2018-01-16T05:13:18.293286+00:00 heroku[router]: at=info method=GET
path="/" host=polar-taiga-65467.herokuapp.com
request_id=99bf3dd0-59b3-4438-a3f7-36a037174b55 fwd="24.15.217.85" dyno=web.1 connect=0ms service=22ms status=500 bytes=1827
protocol=https
Simple_pages/index.html.erb code below:
<h1 style="color:red;">MoraliTee</h1>
<p>Welcome! We are on a mission to give back to people around the
world</p>
<%= image_tag("yellowtee", class: "img-responsive first-tee")%>
There was a file type missing from the end of my image on my simple_pages/index.html.erb page. I needed to .jpg to the end of my source in my image_tag.
Thank you #mmichael for your help in identifying the issue.
I thought there was something wrong with my db but I was incorrect. Thanks for your help.

Weird application error caused by "MultiJson::DecodeError: 795: unexpected token"

I'm building an application which creates PDF documents with maps of trips created by the users. It has two stages:
Personalization - users choose points of interests.
Finalization - users enter their e-mail address, we generate PDF maps and finalize the process by sending e-mail with a download link.
I have a problem with the second stage of the process. I get an error when requesting to generate a PDF.
In logs:
app[worker.1]: Starting to finalize PDF no #3384
app[worker.1]: Generating pdf url:/pdfs/new.json?id=3384&token=abcdeyd
app[web.2]: Started GET "/pdfs/new.json?id=3384&token=abcdeyd"
After few seconds I get:
heroku[router]: at=error code=H12 desc="Request timeout" method=GET path=/pdfs/new.json?id=3384&token=abcdeyd" host= fwd= dyno=web.2 queue=0ms wait=0ms connect=1ms service=30000ms status=503 bytes=0
And then:
[Worker(host:pid:2)] Trip#finalize_without_delay! failed with MultiJson::DecodeError: 795: unexpected token at '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
app[worker.1]: <html>
app[worker.1]: <head>
app[worker.1]: <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
app[worker.1]: <style type="text/css">
app[worker.1]: html, body, iframe { margin: 0; padding: 0; height: 100%; }
app[worker.1]: iframe { display: block; width: 100%; border: none; }
app[worker.1]: </style>
app[worker.1]: <title>Application Error</title></head>
app[worker.1]: </head>
app[worker.1]: <body>
app[worker.1]: <iframe src="//s3.amazonaws.com/heroku_pages/error.html">
app[worker.1]: <p>Application Error</p>
app[worker.1]: </iframe>
app[worker.1]: </body>
app[worker.1]: </html>' - 0 failed attempts
From the user's side, it goes like this:
app[web.1]: Started GET "/pdfs/3384"
app[web.1]: OpenURI::HTTPError (403 Forbidden):
app[web.1]: app/controllers/pdfs_controller.rb:52:in `show'
And the weirdest part of this is that when I actually tried downloading the PDF after about 30-40 minutes, everything went well and I downloaded it to my computer.
app[web.1]: cache: [GET /pdfs/3384] miss
app[web.1]: Processing by PdfsController#show as HTML
app[web.1]: Parameters: {"id"=>"3384"}
app[web.1]: Completed 200 OK in 2101ms (Views: 0.9ms | ActiveRecord: 7.4ms | Solr: 0.0ms)
heroku[router]: at=info method=GET path=/pdfs/3384 dyno=web.1 queue=0 wait=1ms connect=1ms service=4220ms status=200 bytes=13825239
I'd be very thankful for any suggestions. Please ask if something isn't clear enough.
Greetings

Rails Mobiscroll not working on Heroku

I have a Rails app and I just installed gem 'mobiscroll-rails'.
I got it working in development on my iMac. But, when I run it on Heroku, I get:
ActionController::RoutingError (No route matches [GET] "/apple-touch-icon-precomposed.png"):
app[web.1]: cache: [GET /apple-touch-icon-precomposed.png] miss
heroku[router]: at=info method=GET path=/apple-touch-icon-precomposed.png host=www.requestsys.com fwd=70.34.1.156 dyno=web.1 queue=0 wait=0ms connect=5ms service=8ms status=404 bytes=728
heroku[nginx]: 70.34.1.156 - - [20/Jan/2013:23:58:46 +0000] "GET /apple-touch-icon-precomposed.png HTTP/1.1" 404 728 "-" "MobileSafari/8536.25 CFNetwork/609 Darwin/13.0.0" www.requestsys.com
app[web.1]: Started GET "/apple-touch-icon.png" for 70.34.1.156 at 2013-01-20 16:58:47 -0700
ActionController::RoutingError (No route matches [GET] "/apple-touch-icon.png"):
cache: [GET /apple-touch-icon.png] miss
"GET /apple-touch-icon.png HTTP/1.1" 404 728 "-" "MobileSafari/8536.25 CFNetwork/609 Darwin/13.0.0" www.requestsys.com
at=info method=GET path=/apple-touch-icon.png host=www.requestsys.com fwd=70.34.1.156 dyno=web.1 queue=0 wait=0ms connect=3ms service=7ms status=404 bytes=728
My application.html.erb has:
<!-- Le fav and touch icons -->
<link href="images/favicon.ico" rel="shortcut icon">
<link href="images/apple-touch-icon.png" rel="apple-touch-icon">
<link href="images/apple-touch-icon-72x72.png" rel="apple-touch-icon" sizes="72x72">
<link href="images/apple-touch-icon-114x114.png" rel="apple-touch-icon" sizes="114x114">
Thanks!
UPDATE -- now I'm getting this:
ActionView::Template::Error (Invalid CSS after ".ios td:": expected pseudoclass or pseudoelement, was " first-child .d..."
(in /app/app/assets/stylesheets/application.css)):
17: }
18:
19:
20: <%= stylesheet_link_tag "application", :media => "all" %>
app/views/layouts/application.html.erb:20:in `_app_views_layouts_application_html_erb__4520300412125467599_68152740'
Looks like some invalid CSS somewhere in the mobiscroll-rails gem. I got it locally when I bundled:
gem 'mobiscroll-rails'
and did rake assets:precompile, which is what's happening on Heroku during asset compilation. I loaded the version from the git repo and was able to precompile just fine:
gem 'mobiscroll-rails', :git => 'https://github.com/crushlovely/mobiscroll-rails.git'
EDIT: Alternatively, you can try this gem that just came out a couple of days ago:
https://github.com/Dinuz/mobiscroll-rails.git

Rails: Why is this form triggering the wrong action?

I have a form in my app which is triggering the wrong controller action. Here's the rendered form:
<form id="edit_profile_1" class="simple_form profile windowed" method="post" enctype="multipart/form-data" action="/profiles/1" accept-charset="UTF-8">
<div style="margin:0;padding:0;display:inline">
<input type="hidden" value="✓" name="utf8">
<input type="hidden" value="put" name="_method">
<input type="hidden" value="..." name="authenticity_token">
</div>
....
</form>
So, pretty much a normal form. On my local environment this works fine, it triggers the profiles#update action. However, when deployed on Heroku for some reason this is triggering the profiles#show action, and therefore is not working.
What gives? Has anyone encountered this error before, and do you know how to fix it?
-EDIT- #Laas: Here's the production log:
2011-05-20T21:41:38+00:00 app[web.1]: Started GET "/account" for 98.201.59.6 at 2011-05-20 14:41:38 -0700
2011-05-20T21:41:40+00:00 heroku[router]: GET www.fourthenvironment.org/account dyno=web.1 queue=0 wait=0ms service=2212ms bytes=8672
2011-05-20T21:41:40+00:00 app[web.1]: Connected to NewRelic Service at collector-6.newrelic.com:80
2011-05-20T21:41:40+00:00 heroku[router]: GET www.fourthenvironment.org/javascripts/rails.js dyno=web.1 queue=0 wait=0ms service=2ms bytes=5176
2011-05-20T21:41:41+00:00 heroku[router]: GET www.fourthenvironment.org/javascripts/jquery.144.min.js dyno=web.1 queue=0 wait=0ms service=3ms bytes=78865
2011-05-20T21:41:42+00:00 heroku[router]: GET www.fourthenvironment.org/stylesheets/style.css dyno=web.1 queue=0 wait=0ms service=3ms bytes=63444
2011-05-20T21:41:47+00:00 heroku[router]: GET www.fourthenvironment.org/favicon.ico dyno=web.1 queue=0 wait=0ms service=4ms bytes=1672
2011-05-20T21:41:50+00:00 app[web.1]:
2011-05-20T21:41:50+00:00 app[web.1]:
2011-05-20T21:41:50+00:00 app[web.1]: Started POST "/profiles/1" for 98.201.59.6 at 2011-05-20 14:41:50 -0700
2011-05-20T21:41:50+00:00 heroku[router]: POST www.fourthenvironment.org/profiles/1 dyno=web.1 queue=0 wait=0ms service=102ms bytes=420
2011-05-20T21:41:50+00:00 app[web.1]: THIS SHOULD NOT BE TRIGGERED
2011-05-20T21:41:50+00:00 heroku[router]: GET www.fourthenvironment.org/profiles/1 dyno=web.1 queue=0 wait=0ms service=30ms bytes=414
2011-05-20T21:41:50+00:00 app[web.1]:
2011-05-20T21:41:50+00:00 app[web.1]:
2011-05-20T21:41:50+00:00 app[web.1]: Started GET "/account" for 98.201.59.6 at 2011-05-20 14:41:50 -0700
Note the "THIS SHOULD NOT BE TRIGGERED". Here's the controller:
class ProfilesController < ApplicationController
before_filter :authenticate_user!
def show
puts "THIS SHOULD NOT BE TRIGGERED"
redirect_to account_path
end
def edit
#profile = Profile.find(params[:id])
end
def update
puts "profiles#update"
#profile = Profile.find(params[:id])
if #profile.update_attributes(params[:profile])
redirect_to account_path, :notice => t('user.notice.updated')
else
render :action => 'edit'
end
end
end
It turns out the issue was related to the use of the SSL-Requirement Gem. For some reason if you send a request from an SSL page to a non-SSL page while using SSL-requirement it gets redirected. So, to fix, enable SSL-requirement on both ends of the request, and it will work. It looks like going from SSL to non SSL the gem only allows gets -- hence the bug. This looks to be irrelevant as of Rails 3.1 since a new SSL requirement functionality will be baked-in and the gem will not be required.
Many thanks to the Heroku staff for helping isolate this.
Seems to be identical to this problem routing-issues-with-multi-part-forms-on-heroku.
As it is only few days old, maybe it is not a coincidence and there's something awry with Heroku?
Why is the form tag hard coded? Use the form_tag helper
http://api.rubyonrails.org/classes/ActionView/Helpers/FormTagHelper.html

Resources