Class: EricWeixin::Cms::Weixin::NewsDatasController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/eric_weixin/cms/weixin/news_datas_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



14
15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/eric_weixin/cms/weixin/news_datas_controller.rb', line 14

def create
  begin
    @news_data = ::EricWeixin::News.create_news_datas( weixin_news_data_param,
                                                       params[:weixin_news][:weixin_article_data_ids],
                                                       params[:weixin_news][:weixin_article_data_sort]
    )
    redirect_to "/eric_weixin/cms/weixin/news_datas/#{@news_data.id}/edit", notice: '微信图文消息创建成功.'
  rescue Exception => e
    render :edit
  end
end

#editObject



10
11
12
# File 'app/controllers/eric_weixin/cms/weixin/news_datas_controller.rb', line 10

def edit
  @news_data = ::EricWeixin::News.find(params[:id])
end

#indexObject



2
3
4
# File 'app/controllers/eric_weixin/cms/weixin/news_datas_controller.rb', line 2

def index
  @news_datas = ::EricWeixin::News.all.paginate(page: params[:page], per_page: 10)
end

#newObject



26
27
28
# File 'app/controllers/eric_weixin/cms/weixin/news_datas_controller.rb', line 26

def new
  @news_data = ::EricWeixin::News.new
end

#showObject



6
7
8
# File 'app/controllers/eric_weixin/cms/weixin/news_datas_controller.rb', line 6

def show
  @news_data = ::EricWeixin::News.find(params[:id])
end

#updateObject



30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/controllers/eric_weixin/cms/weixin/news_datas_controller.rb', line 30

def update
  begin
    @news_data = ::EricWeixin::News.update_news_datas(params[:id],
                                                      weixin_news_data_param,
                                                      params[:weixin_news][:weixin_article_data_ids],
                                                      params[:weixin_news][:weixin_article_data_sort]
    )

    redirect_to "/eric_weixin/cms/weixin/news_datas/#{@news_data.id}/edit", notice: '微信图文消息更新成功.'
  rescue Exception => e
    render :edit
  end
end