@saberma 简历已发
#3 楼 @flowerwrong 我用https://github.com/Eric-Guo/wechat 这个 gem 解决了,认证和菜单之类的都搞定了。我觉得有些人写 gem 误人子弟,自己技术就不咋地,文档残缺不全,词不达意,云里雾里,还不维护。总之谢谢你了。
#1 楼 @flowerwrong 谢谢了,我试着弄一下你的建议,我想问你另外一个问题。 https://github.com/goofansu/wechat-starter 这个 gem,配置按这里 https://github.com/goofansu/wechat-starter/wiki/%E5%BE%AE%E4%BF%A1%E5%BC%80%E5%8F%91%E7%9A%84%E5%9F%BA%E6%9C%AC%E9%85%8D%E7%BD%AE 都弄好了,然后 url+token 的验证,访问这个地址http://m.your_domain.com/wechat 结果是 Forbidden console 信息
Started GET "/wechat/?signature=4f4a6bab2783c80c8aa6059044d6de403438d861&echostr=1176759902270124019×tamp=1486988978&nonce=467979794" for 192.168.10.1 at 2017-02-13 12:29:38 +0000
Cannot render console from 192.168.10.1! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
Processing by WechatsController#show as */*
Parameters: {"signature"=>"4f4a6bab2783c80c8aa6059044d6de403438d861", "echostr"=>"1176759902270124019", "timestamp"=>"1486988978", "nonce"=>"467979794"}
Rendering text template
Rendered text template (0.0ms)
Completed 200 OK in 2ms (Views: 1.9ms | ActiveRecord: 0.0ms)
为啥是 Forbidden,我的开发 环境是 vagrant 然后用 ngrok 映射的
请问@current_public_account 如何定义,不是很明白,还有 ENV["APPID"], ENV["APPSECRET"] 这俩个再哪里声明赋值?
@goofansu 你好,我在本地的开发环境用 ngrok 映射到公网,微信公众平台配置接口信息的时候,无法通过。url 是 http://????.ngork.cc/wechat token 也一致,无法成功配置。我用浏览器访问 http://????.ngork.cc/wechat,显示 Forbidden。 console 的信息
vagrant@vagrant-ubuntu-trusty-64:/vagrant/weixin$ rails s -b 192.168.10.10
=> Booting Puma
=> Rails 5.0.1 application starting in development on http://192.168.10.10:3000
=> Run `rails server -h` for more startup options
Puma starting in single mode...
* Version 3.6.2 (ruby 2.3.0-p0), codename: Sleepy Sunday Serenity
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://192.168.10.10:3000
Use Ctrl-C to stop
Started GET "/wechat" for 192.168.10.1 at 2017-02-12 18:28:31 +0000
ActiveRecord::SchemaMigration Load (0.4ms) SELECT "schema_migrations".* FROM "schema_migrations"
Processing by WechatsController#show as HTML
Rendering text template
Rendered text template (0.0ms)
Filter chain halted as :verify_signature rendered or redirected
Completed 403 Forbidden in 32ms (Views: 15.6ms | ActiveRecord: 0.0ms)
Started GET "/wechat?signature=7f19626f401dcad1c53f214244d6fbd4752b5cc6&echostr=2528414796461682171×tamp=1486924145&nonce=1748360740" for 192.168.10.1 at 2017-02-12 18:29:06 +0000
Processing by WechatsController#show as */*
Parameters: {"signature"=>"7f19626f401dcad1c53f214244d6fbd4752b5cc6", "echostr"=>"2528414796461682171", "timestamp"=>"1486924145", "nonce"=>"1748360740"}
Rendering text template
Rendered text template (0.0ms)
Completed 200 OK in 2ms (Views: 1.7ms | ActiveRecord: 0.0ms)
如何通过微信的接口认证,谢谢了!
#8 楼 @Katrina123 放到 public 目录下,然后就可以用了。实在不行,你把模版贴出来我帮你试试看!
@kayakjiang @w7938940 @flowerwrong @gyorou 谢谢各位,解决了!
#3 楼 @flowerwrong 能再说的具体点吗,http://zjyd.sc.chinaz.com/Files/DownLoad/moban/201403/chahua3215.rar 如何把这个集成到一个新的的 rails 项目里面,谢谢啊
#4 楼 @qinfanpeng 我自己先找找看,初学者还不是很懂 rails ,因为关了 turbolink 一个页面读取进度条的 gem 就不能用了,谢谢你啊
#6 楼 @classicalliu 'data-toggle': 'dropdown' 前面可以加引号 没有想到 api 已经看过了 也用过这个 block 关键是 我试的前面没加引号
#4 楼 @classicalliu 受教了 谢谢你啊 这次没问题了 do end 用法具体说说 我学习一下
#1 楼 @small_fish__ 这么写会报错,主要是 data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"这部分不知道如何写 用 html_option 也有问题
#1 楼 @davidzhu001 你是在逗我么
#10 楼 @zhang_soledad /vagrant/yameidie/app/controllers/carts_controller.rb:77: syntax error, unexpected ',', expecting ')' redirect_to ({action: 'index'},notice: "fdsaf") ^ /vagrant/yameidie/app/controllers/carts_controller.rb:77: syntax error, unexpected ')', expecting keyword_end
redirect_to store_url, notice: 'Invalid cart'
我按照你的改了,受教了,代码比我的好多了。 然后报错 undefined local variable or method `store_url' for #CartsController:0x007fd4786b1a08 这个 store_url 他找不到,是不是 routes.rb 需要加东西?
class StoreController < ApplicationController
def index
@products = Product.all
end
end
class CartsController < ApplicationController
before_action :set_cart, only: [:show, :edit, :update, :destroy]
# GET /carts
# GET /carts.json
def index
@carts = Cart.all
end
# GET /carts/1
# GET /carts/1.json
def show
end
# GET /carts/new
def new
@cart = Cart.new
end
# GET /carts/1/edit
def edit
end
# POST /carts
# POST /carts.json
def create
@cart = Cart.new(cart_params)
respond_to do |format|
if @cart.save
format.html { redirect_to @cart, notice: 'Cart was successfully created.' }
format.json { render :show, status: :created, location: @cart }
else
format.html { render :new }
format.json { render json: @cart.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /carts/1
# PATCH/PUT /carts/1.json
def update
respond_to do |format|
if @cart.update(cart_params)
format.html { redirect_to @cart, notice: 'Cart was successfully updated.' }
format.json { render :show, status: :ok, location: @cart }
else
format.html { render :edit }
format.json { render json: @cart.errors, status: :unprocessable_entity }
end
end
end
# DELETE /carts/1
# DELETE /carts/1.json
def destroy
@cart.destroy
respond_to do |format|
format.html { redirect_to carts_url, notice: 'Cart was successfully destroyed.' }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_cart
begin
@cart = Cart.find(params[:id])
rescue ActiveRecord::RecordNotFound
logger.error "Attempt to access invalid cart #{params[:id]}"
redirect_to ({controller: 'store', action: 'index'}, notice:"fdsaf")#notice: 'Invalid cart' #没有提示日的
else
respond_to do |format|
format.html #show.html.erb
format.json { render json: @cart}
end
end
end
# Never trust parameters from the scary internet, only allow the white list through.
def cart_params
params[:cart]
end
end
<% if notice %>
<p id= "notice"><%= notice %> </p>
<% end %>
<% @products.each do |product| %>
<div class="portfolio food" data-cat="logo">
<div class="portfolio-wrapper">
<%= image_tag(product.image_url) %>
<div class="label">
<div class="label-text">
<a class="text-title"><%= product.title %></a>
<%= button_to '加入购物车',
line_items_path(:product_id => product),
:class =>"cart" %>
<span class="text-category"><%= product.price %></span>
</div>
<div class="label-bg"></div>
</div>
</div>
</div>
<% end %>
这是全部代码
#4 楼 @chunlea 我感觉我还是没说清楚,我理解的 i18n 是把自己的项目国际化,我现在是要把日本亚马逊http://www.amazon.co.jp/的主框架翻译了,其他都不动,还有注册购物支付流程汉化了,需要如何写代码!