Ruby China
  • 社区
  • 招聘
  • Wiki
  • 酷站
  • Gems
  • 注册
  • 登录
余海玲
@babyhai
会员
第 28871 位会员 / 2016-10-09

上海创宇技术信息发展有限公司
上海
15 篇帖子 / 199 条回帖
16 关注者
22 正在关注
54 收藏
GitHub Public Repos
More on GitHub
  • 概况
  • 话题
  • 回帖
  • 收藏
  • 正在关注
  • 关注者
  • [上海] 不加班 (15k~30k+) PwC SDC 招聘 软件测试开发工程师 (15 名) + node (10 名) + angular (10 名) 工程师 at 2018年11月12日

    已投简历

  • 新手求《Rails 5 敏捷开发中文版》,英文的看不懂,已崩溃 at 2018年06月07日

    kindle 绝对就是移动的纸质书,关键是我买了很多书 20 几本 我 16 年 7 月才来上海的啊 搬家都不整

  • 新手求《Rails 5 敏捷开发中文版》,英文的看不懂,已崩溃 at 2018年06月07日

    我买了还没看,不过能买到电子版的就好了可以放到 kindle 上

  • 用 Rails 5 + 纯 webpacker 做了一个小网站 at 2018年03月28日

    地址定位这一块 你是用的什么 gem

  • 展示一下自己的第一个 Rails 作品 - clwy.cn at 2018年03月27日

    哦 好吧 从用户的角度 这里可能 不太建议这么设计

  • 展示一下自己的第一个 Rails 作品 - clwy.cn at 2018年03月27日

    是的,武汉如果有,我肯定会考虑会武汉的 你的网站我刚刚看了下,前端样式还有些问题

  • 展示一下自己的第一个 Rails 作品 - clwy.cn at 2018年03月27日

    赞一个,不过武汉的公司 ruby 的确很少,所以我去魔都了😇

  • 练手做的一个 Rails 5 项目 Airoom,开源中 at 2018年03月23日

    你看的是什么教程,可以分享一下?

  • 练手做的一个 Rails 5 项目 Airoom,开源中 at 2018年03月21日

    我还没有弄过 smtp 的邮箱 好吧

  • 练手做的一个 Rails 5 项目 Airoom,开源中 at 2018年03月20日

    运行了一下 发现开发模式下注册还是有些问题,另外想问问楼主 配置百度地图是怎么配置网上配置 geocoder 的资料还是很少

  • [上海] 赛若福诚聘 Ruby 工程师 at 2018年03月19日

    ok

  • [上海] 赛若福诚聘 Ruby 工程师 at 2018年03月19日

    我就是问问,不过你见过我?

  • [上海] 赛若福诚聘 Ruby 工程师 at 2018年03月19日

    贵公司是使用 gem 写 API 还是?

  • [上海][2018年03月20日] Ruby 聚会召集 at 2018年03月15日

    这算报名成功了么,好想听听

  • [上海][2018年03月20日] Ruby 聚会召集 at 2018年03月15日

    报名

  • [上海] “来了网” 欢迎爱好 Ruby,好学上进的你加入 at 2018年03月14日

    顶一个😁

  • 上次说的资源权限管理的功能,写成 Gem 包了 at 2018年03月12日

    看不懂 好像

  • [上海] [徐汇] PIPI Hosting 招聘 Ruby 后端 / 全栈 (全职 & 实习 - 2018 春) at 2018年03月12日

    你的简历还是去年那个,没改改

  • [上海] [徐汇] PIPI Hosting 招聘 Ruby 后端 / 全栈 (全职 & 实习 - 2018 春) at 2018年03月09日

    所以你投简历没有😁

  • [上海] 微问家 2018 年 招 Ruby 实习生 15 名 at 2018年03月09日

    赞一个

  • [上海 / 浦东] 交大创业公司迈科技-MetaLab 招聘 Ruby 后端工程师 at 2018年03月07日

    加油

  • [上海 / 浦东] 交大创业公司迈科技-MetaLab 招聘 Ruby 后端工程师 at 2018年03月06日

    @railsboy 你可以试试

  • 送书 ---《Rails 5 敏捷开发》 at 2018年01月26日

    这个怎么抽啊 看看我运气怎么样

  • 送几本《Rails 5 敏捷开发》 at 2018年01月25日

    太赞了,可以购买电子版的么

  • 看着源码操作的 controller 下的 application_controller.rb 出错 at 2018年01月24日

    不行 还是报错

  • 看着源码操作的 controller 下的 application_controller.rb 出错 at 2018年01月24日

    好的

  • 看着源码操作的 controller 下的 application_controller.rb 出错 at 2018年01月24日

    这是目录

  • 看着源码操作的 controller 下的 application_controller.rb 出错 at 2018年01月24日

  • 看着源码操作的 controller 下的 application_controller.rb 出错 at 2018年01月24日

    TopicsController

    module Homeland
      class TopicsController < Homeland::ApplicationController
        before_action :authenticate_user!, only: [:new, :edit, :create, :update, :destroy, :reply]
        before_action only: [:edit, :update, :destroy] do
          authorize_resource! topic
        end
    
        def index
          @topics = Topic.latest.includes(:user).page(params[:page])
    
          set_seo_meta(t("homeland.nav.latest"))
        end
    
        def node
          @node = Node.find(params[:id])
          @topics = @node.topics.latest.includes(:user).page(params[:page])
    
          render action: "index"
        end
    
        %w(recent features).each do |action|
          define_method(action) do
            @topics = Topic.send(action).includes(:user, :node).page(params[:page])
    
            set_seo_meta(t("homeland.nav.#{action}"))
    
            render action: "index"
          end
        end
    
        def show
          @topic = Topic.find(params[:id])
          @replies = replies
    
          set_seo_meta(@topic.title)
        end
    
        def new
          @topic = Topic.new
          @node = Node.find_by(id: params[:node_id])
    
          set_seo_meta(t("homeland.nav.new"))
        end
    
        def reply
          @topic = Topic.find(params[:id])
          @reply = @topic.replies.build(reply_params)
          @reply.user_id = current_user.id
          if @reply.save
            flash[:notice] = t('homeland.reply_created')
          else
            flash[:alert] = @reply.errors.full_messages.join("<br />")
          end
          redirect_to topic_path(params[:id],:anchor => "reply")
        end
    
        # GET /topics/1/edit
        def edit
          @node = @topic.node
        end
    
        # POST /topics
        # POST /topics.xml
        def create
          @topic = Topic.new(topic_params)
          @topic.user_id = current_user.id
    
          if @topic.save
            redirect_to(topic_path(@topic.id), notice: t('homeland.topic_created'))
          else
            render action: "new"
          end
        end
    
        # PUT /topics/1
        # PUT /topics/1.xml
        def update
          @topic = Topic.find(params[:id])
    
          if @topic.update_attributes(topic_params)
            redirect_to(topic_path(@topic.id), notice: t('homeland.topic_updated'))
          else
            render action: "edit"
          end
        end
    
        # DELETE /topics/1
        # DELETE /topics/1.xml
        def destroy
          topic.destroy
          redirect_to(topics_path, notice: t('homeland.topic_deleted'))
        end
    
        private
    
        def topic
          @topic ||= Topic.find(params[:id])
        end
    
        def replies
          @topic.replies.includes(:user).page(params[:page])
        end
    
        def topic_params
          params.require(:topic).permit(:node_id, :title, :body)
        end
    
        def reply_params
          params.require(:reply).permit(:body, :reply_to_id)
        end
      end
    end
    
    

    application_controller

    module Homeland
      class ApplicationController < ::ApplicationController
        helper Homeland::ActionView::WillPaginate
        helper Homeland::ApplicationHelper
    
        helper_method :current_user, :owner?, :admin?
    
        alias_method :origin_current_user, Homeland.config.current_user_method.to_sym
        alias_method :origin_authenticate_user!, Homeland.config.authenticate_user_method.to_sym
    
        def current_user
          origin_current_user
        end
    
        def authenticate_user!
          origin_authenticate_user!
        end
    
        def authorize_resource!(obj)
          if !owner?(obj)
            redirect_to homeland.root_path, alert: t('homeland.access_denied')
          end
        end
    
        def authorize_admin!
          if !admin?
            redirect_to homeland.root_path, alert: t('homeland.access_denied')
          end
        end
    
        def set_seo_meta(title = '', meta_keywords = '', meta_description = '')
          @page_title = "#{title}" if title.length > 0
          @meta_keywords = meta_keywords
          @meta_description = meta_description
        end
    
        def owner?(obj)
          return false if obj.blank?
          return false if current_user.blank?
          return true if current_user.send(Homeland.config.user_admin_method) == true
    
          obj.user_id == current_user.id
        end
    
        def admin?
          return false if current_user.blank?
          current_user.send(Homeland.config.user_admin_method) == true
        end
      end
    end
    
    
  • 作品:开门社区 kaimen.me,一个好用的个人首页 at 2018年01月23日

    看了下,有些不明白有什么用处 只是记录生活

  • 1
  • 2
  • 3
  • …
  • 6
  • 7
  • 下一页
关于 / RubyConf / Ruby 镜像 / RubyGems 镜像 / 活跃会员 / 组织 / API / 贡献者
由众多爱好者共同维护的 Ruby 中文社区,本站使用 Homeland 构建,并采用 Docker 部署。
服务器由 赞助 CDN 由 赞助
iOS 客户端 / Android 客户端 简体中文 / English