저는 이것을 아무 소용이없는 것으로 처리하려고 노력해 왔습니다. 그것은 나를 미치게합니다. 보통, 나는 이런 식으로 잠을 자고 아침에 오타가 있음을 깨닫습니다. 그러나 나는 이것을 알아낼 때까지 잠을 자지 못한다. 어쨌든 나는 질문의 색인을 가지고있다. 각 질문의 제목은 그 자체에 대한 링크이다. 거기에 놀라운 일이 없습니다. 그리고 그것은 로컬 호스트에서 작동합니다. heroku에 배포 할 때 올바른 링크로 안내한다는 것을 알 수 있으며 링크를 가리면 정확하게 라우팅됩니다. (즉, myapp.herokuapp.com/questions/2). 나는 확실히 블록에 question_path (question)로 설정된 링크를 가지고있다. 그러나 링크를 클릭하면 questions_path로 이동하고 질문 목록으로 돌아갑니다. 나를 미치게 만들었다. 누구나 전에 이런 문제가 있습니까?Ruby Rails 내 링크가 heroku에서 작동하지 않습니다
index.html.erb보기 :
<% if @quests.present? %>
<% @quests.each do |question| %>
<div class="booyah-box col-xs-10 col-xs-offset-1">
<center>
<bptitle>
<%= link_to question.qtitle.html_safe, question_path(question) %>
</bptitle>
<br />
<bpauthor> A question by <%= question.user.firstname %> <%= question.user.lastname %>, from
<%= question.user.organization.name %></bpauthor>
</center>
<br />
<%= question.qbody.split[0..10].join(" ").html_safe %>... <br /><br />
Answers: <%= question.answers.count %><br />
</div>
<% end %>
<% else %>
<p>There are no posts containing the term(s) <%= params[:search] %>.</p>
<% end %>
</center>
questions_controller :
def index
if params[:search] != nil
@quests = Question.search(params[:search]).order("created_at DESC")
else
@quests = Question.all.order('created_at DESC')
end
end
def show
@question = Question.find(params[:id])
@answer = Answer.new
@faveanswer = Favanswer.new
@ans = Answer.find(params[:id])
@qids = []
@qaids = []
Favanswer.all.each do |favanswer|
@qids << favanswer.question_id
@qaids << [favanswer.question_id, favanswer.answer_id]
end
end
질문 모델 :
class Question < ActiveRecord::Base
include Bootsy::Container
mount_uploader :bootsy, BootsyUploader
belongs_to :user
has_many :answers
has_one :favanswer
def self.search(search)
where("qtitle LIKE ? OR qbody LIKE ?", "%#{search}%", "%#{search}%")
end
end
오타가 있다고 말해주십시오. 내가 도와 준다면 나는 너의 발에 입맞춤을 할 것이다. 나는 잠이 필요해. 아래 앤드류의 코멘트 당 내 Heroku가 로그와
편집 :
2016-08-01T13:54:20.800626+00:00 app[web.1]: Started GET "https://stackoverflow.com/questions/3" for 162.244.49.116 at 2016-08-01 13:54:20 +0000
2016-08-01T13:54:20.803208+00:00 app[web.1]: Processing by QuestionsController#show as HTML
2016-08-01T13:54:20.803238+00:00 app[web.1]: Parameters: {"id"=>"3"}
2016-08-01T13:54:20.806102+00:00 app[web.1]: User Load (1.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT 1 [["id", 1]]
2016-08-01T13:54:20.809813+00:00 app[web.1]: Question Load (0.8ms) SELECT "questions".* FROM "questions" WHERE "questions"."id" = $1 LIMIT 1 [["id", 3]]
2016-08-01T13:54:20.833346+00:00 app[web.1]: Redirected to http://mypretendapp.herokuapp.com/questions
당신의 기록은 영웅에서 무엇이라고 말합니까? 인덱스 메서드로 리디렉션하는 방법에 대한 모든 메모? 'rescue_from' 메소드는 어떨까요? 영웅에 대한 잘못된 데이터로 인해 찾을 수 없기 때문에 무언가가 리디렉션 될 수 있습니까? – Andrew
누군가 대답 할 수 있습니까? 나는 그것에 너무 붙어있다. 루프가 있습니다. 그리고 <% = link_to service.website, service.website, : target => '_blank', rel : "nofollow"%> 작동하지 않습니다. –