FIX update setting api for nav bar url
This commit is contained in:
		
							parent
							
								
									c07c570061
								
							
						
					
					
						commit
						aa23762b2f
					
				| 
						 | 
				
			
			@ -2,5 +2,10 @@ class SettingsController < ApplicationController
 | 
			
		|||
  def show
 | 
			
		||||
    @old_projects_url = nil
 | 
			
		||||
    @old_projects_url = "https://www.trustie.net/users/#{current_user.try(:login)}/projects"  if User.current.logged?
 | 
			
		||||
 | 
			
		||||
    @add =  Site.add
 | 
			
		||||
    @personal = User.current.logged? ? Site.personal : []
 | 
			
		||||
 | 
			
		||||
    # @sites = Site.group(:site_type).select(:name, :url, :key)
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,23 @@
 | 
			
		|||
# == Schema Information
 | 
			
		||||
#
 | 
			
		||||
# Table name: sites
 | 
			
		||||
#
 | 
			
		||||
#  id         :integer          not null, primary key
 | 
			
		||||
#  name       :string(255)
 | 
			
		||||
#  url        :string(255)
 | 
			
		||||
#  key        :string(255)
 | 
			
		||||
#  site_type  :integer
 | 
			
		||||
#  created_at :datetime         not null
 | 
			
		||||
#  updated_at :datetime         not null
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
class Site < ApplicationRecord
 | 
			
		||||
  # add: 添加类链接
 | 
			
		||||
  # personal: 个人名下类链接,
 | 
			
		||||
  # common: 普通链接
 | 
			
		||||
  enum site_type: { add: 0, personal: 1, common: 2 }
 | 
			
		||||
 | 
			
		||||
  def self.set_default
 | 
			
		||||
    
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			@ -47,5 +47,12 @@ json.setting do
 | 
			
		|||
  json.new_course default_course_links
 | 
			
		||||
  json.old_projects_url @old_projects_url
 | 
			
		||||
 | 
			
		||||
  json.add do
 | 
			
		||||
    json.array! @add, :name, :url, :key
 | 
			
		||||
  end
 | 
			
		||||
  
 | 
			
		||||
  json.personal do
 | 
			
		||||
    json.array! @personal, :name, :url, :key
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -23,7 +23,6 @@ Rails.application.routes.draw do
 | 
			
		|||
 | 
			
		||||
  resources :edu_settings
 | 
			
		||||
 | 
			
		||||
  resources :edu_settings
 | 
			
		||||
  scope '/api' do
 | 
			
		||||
    namespace :ci  do
 | 
			
		||||
      resources :languages, only: [:index, :show] do
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,12 @@
 | 
			
		|||
class CreateSites < ActiveRecord::Migration[5.2]
 | 
			
		||||
  def change
 | 
			
		||||
    create_table :sites do |t|
 | 
			
		||||
      t.string :name, comment: "中文名称"
 | 
			
		||||
      t.string :url, comment: "具体链接"
 | 
			
		||||
      t.string :key, comment: "标识"
 | 
			
		||||
      t.integer :site_type, comment: "分类,按照分类编排链接"
 | 
			
		||||
 | 
			
		||||
      t.timestamps
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
		Loading…
	
		Reference in New Issue