Обновление Я исправил это, удалив укороченные теги descritpion и HTML -Безопасные теги. Не совсем то, что я хотел, потому что мне все еще нужна эта функция, но, наконец, сайт работает, и я могу выяснить, в чем проблема.
Я пытался урезать описание поста в блоге, но это не так работать, поэтому я удалил все, что связано с усечением. Мое приложение rails работает над разработкой, но не отображает домашнюю страницу в рабочей среде heroku, хотя остальные страницы любят / blog и / статьи. Ссылка на сайт: https://www.xrloaded.com Ссылка на мой репо: https://github.com/maxrosales83/findXRJobs
Я хочу устранить ошибку и снова загрузить домашнюю страницу.
Я ценю любую помощь. Спасибо.
Я не уверен, почему отображается ошибка. Я искал ответы, но ничего не имело смысла. Вот моя модель статей:
class Article < ActiveRecord::Base
belongs_to :user , :optional => true
mount_uploader :blogimage, AvatarUploader
def admin?
admin
end
end
Вот мой контроллер статей:
class ArticlesController < ApplicationController
before_action :set_article, only: [:edit, :update, :show, :destroy]
before_action :authenticate_user!, except: [:index]
def new
@article = Article.new
end
def index
@articles = Article.limit(3).order("id desc")
@secondrow = Article.limit(3).offset(3).order("id desc")
end
def create
#render plain: params[:article].inspect
@article = Article.new(article_params)
if @article.save
flash[:notice] = "Article was successfully created"
redirect_to article_path(@article)
else
render 'new'
end
end
def edit
end
def update
if @article.update(article_params)
flash[:notice] = "Article was updated"
redirect_to article_path(@article)
else
flash[:notice] = "Article was not updated"
render 'edit'
end
end
def show
end
def destroy
@article.destroy
flash[:notice] = "Article was deleted"
redirect_to articles_path
end
private
def article_params
params.require(:article).permit(:title, :description, :blogimage)
end
def set_article
@article = Article.find(params[:id])
end
end
Представление статей:
<!-- page header (title, etc) -->
<div class="main-header">
<section class="hero">
<div class="hero-body">
<div class="container">
<div class="has-text-centered">
<!-- header && subheader -->
<h1 class="title is-1 is-spaced">XR Loaded Blog</h1>
<!-- end of header && subheader -->
<!-- header nav content -->
<div class="nav-center">
<a class="nav-item" href="https://www.facebook.com/xrloaded/">
<span class="icon">
<i class="fa fa-facebook"></i>
</span>
</a>
<a class="nav-item" href="https://www.instagram.com/xrloadedapp/">
<span class="icon">
<i class="fa fa-instagram"></i>
</span>
</a>
</div>
<!-- end of header nav content -->
</div>
</div>
</div>
</section>
</div>
<!-- end page header -->
<!-- page content -->
<div class="main-content">
<div class="container">
<!-- start of posts -->
<div class="columns has-text-centered">
<!-- start of post -->
<% @articles.each do |article| %>
<div class="column is-4" >
<div class="card">
<!-- image for post -->
<div class="card-image">
<figure class="image is-4by3">
<%= link_to article.title, article_path(article) %>
<% if !article.blogimage.file.nil? %>
<%= link_to image_tag(article.blogimage_url(:thumb),:class => "image is-5by3"), article_path(article) %>
<% end %>
</figure>
</div>
<!-- end of image for post -->
<!-- post header -->
<div class="card-content-header">
<h4 class="title is-4"><a href="post.html"><%= link_to article.title, article_path(article) %></a></h4>
<%= link_to article.description, article_path(article) %>
</div>
<!-- end of post header -->
<!-- post content -->
<div class="card-content">
<div class="content">
<div class="nav-center">
<a class="nav-item" href="">
<span class="icon">
<i class="fa fa-twitter"></i>
</span>
</a>
<a class="nav-item" href="">
<span class="icon">
<i class="fa fa-facebook"></i>
</span>
</a>
<a class="nav-item" href="">
<span class="icon">
<i class="fa fa-instagram"></i>
</span>
</a>
</div>
</div>
<!-- end of post content -->
<!-- post footer -->
<!-- end of post footer -->
</div>
</div>
</div>
<% end %>
<!-- end of post -->
</div>
<div class="columns has-text-centered">
<!-- start of post -->
<% @secondrow.each do |article| %>
<div class="column is-4" >
<div class="card">
<!-- image for post -->
<div class="card-image">
<figure class="image is-4by3">
<%= link_to article.title, article_path(article) %>
<img src="http://placehold.it/700x500" alt="Image">
</figure>
</div>
<!-- end of image for post -->
<!-- post header -->
<div class="card-content-header">
<h4 class="title is-4"><a href="post.html"><%= link_to article.title, article_path(article) %></a></h4>
<%= link_to article.description, article_path(article) %>
</div>
<!-- end of post header -->
<!-- post content -->
<div class="card-content">
<div class="content">
<div class="nav-center">
<a class="nav-item" href="">
<span class="icon">
<i class="fa fa-twitter"></i>
</span>
</a>
<a class="nav-item" href="">
<span class="icon">
<i class="fa fa-facebook"></i>
</span>
</a>
<a class="nav-item" href="">
<span class="icon">
<i class="fa fa-instagram"></i>
</span>
</a>
</div>
</div>
<!-- end of post content -->
<!-- post footer -->
<!-- end of post footer -->
</div>
</div>
</div>
<% end %>
<!-- end of post -->
</div>
<!-- end of posts -->
</div>
</div>
<!-- pagination -->
<div class="pagination-style-custom">
<div class="container has-text-right">
<a class="button is-button-grey pagination-next">Show More Posts</a>
</div>
</div>
<!-- end of pagination -->
</div>
<!-- end of page content -->
Файл схемы:
ActiveRecord::Schema.define(version: 20200112211550) do
create_table "ahoy_events", force: :cascade do |t|
t.integer "visit_id"
t.integer "user_id"
t.string "name"
t.text "properties"
t.datetime "time"
t.index ["name", "time"], name: "index_ahoy_events_on_name_and_time"
t.index ["user_id"], name: "index_ahoy_events_on_user_id"
t.index ["visit_id"], name: "index_ahoy_events_on_visit_id"
end
create_table "ahoy_visits", force: :cascade do |t|
t.string "visit_token"
t.string "visitor_token"
t.integer "user_id"
t.string "ip"
t.text "user_agent"
t.text "referrer"
t.string "referring_domain"
t.text "landing_page"
t.string "browser"
t.string "os"
t.string "device_type"
t.string "country"
t.string "region"
t.string "city"
t.float "latitude"
t.float "longitude"
t.string "utm_source"
t.string "utm_medium"
t.string "utm_term"
t.string "utm_content"
t.string "utm_campaign"
t.string "app_version"
t.string "os_version"
t.string "platform"
t.datetime "started_at"
t.index ["user_id"], name: "index_ahoy_visits_on_user_id"
t.index ["visit_token"], name: "index_ahoy_visits_on_visit_token", unique: true
end
create_table "articles", force: :cascade do |t|
t.string "title"
t.text "description"
t.string "blogimage"
end
create_table "jobs", force: :cascade do |t|
t.string "title"
t.text "description"
t.string "url"
t.string "job_type"
t.string "location"
t.string "job_author"
t.boolean "remote_ok"
t.string "apply_url"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "avatar"
t.integer "user_id"
end
create_table "users", force: :cascade do |t|
t.string "email", default: "", null: false
t.string "encrypted_password", default: "", null: false
t.string "reset_password_token"
t.datetime "reset_password_sent_at"
t.datetime "remember_created_at"
t.integer "sign_in_count", default: 0, null: false
t.datetime "current_sign_in_at"
t.datetime "last_sign_in_at"
t.string "current_sign_in_ip"
t.string "last_sign_in_ip"
t.string "name"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "stripe_id"
t.string "card_brand"
t.string "card_last4"
t.string "card_exp_month"
t.string "card_exp_year"
t.datetime "expires_at"
t.boolean "admin"
t.index ["email"], name: "index_users_on_email", unique: true
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
end
end
Файл маршрутов:
require 'sidekiq/web'
Rails.application.routes.draw do
mount RailsAdmin::Engine => '/admin', as: 'rails_admin'
resources :jobs do
get :search #creates new path for search feature
end
resources :articles
devise_for :users
root to: 'jobs#index'
get '/info' => 'pages#info'
get '/blog' => 'articles#index'
get '/privacy' => 'pages#privacy'
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
get '/emailsignup' => 'emailapi#index'
post '/emailapi/subscribe'=> 'emailapi#subscribe'
end