ruby-on-rails-3

How to use the Rails shopify_app gem with a private API key?

可紊 提交于 2020-01-02 10:15:06
问题 I am trying to use the Rails *shopify_app* gem with a private API key. The documentation for the gem mentions that it's possible to do this but doesn't say how. The instructions are only for a Shopify Partner Account. For a private api key there seems to be no way of specifying the return url . This results in the following response fragment being sent back: {"error":"invalid_request","error_description":"The redirect_uri and application url must have matching hosts"} I've looked around a bit

How to use the Rails shopify_app gem with a private API key?

岁酱吖の 提交于 2020-01-02 10:14:53
问题 I am trying to use the Rails *shopify_app* gem with a private API key. The documentation for the gem mentions that it's possible to do this but doesn't say how. The instructions are only for a Shopify Partner Account. For a private api key there seems to be no way of specifying the return url . This results in the following response fragment being sent back: {"error":"invalid_request","error_description":"The redirect_uri and application url must have matching hosts"} I've looked around a bit

I got the error syntax error, unexpected $end, expecting keyword_end [closed]

点点圈 提交于 2020-01-02 10:04:55
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 years ago . I'm first to ruby, so when i following the Guide(http://guides.rubyonrails.org/getting_started.html) I got the error like: Started GET "/questions" for 127.0.0.1 at 2012-06-07 17:22:36 +0900 SyntaxError (/Users/sookcha/Desktop/Dev/CSap/app/models/question.rb:3: invalid multibyte char (US-ASCII) /Users/sookcha

How do you rollback to a previous Gemfile.Lock?

瘦欲@ 提交于 2020-01-02 10:02:39
问题 I recently ran 'bundle update,' and it updated the Twitter-bootstrap-rails gem to the latest version. Ever since then, the header size has changed, and I would like to roll back to the previous gem versions for all my gems. I tried rolling back to my previous gemfile and bundle updating, but the problem was I didn't specify versions in my gemfile so it doesn't know to degrade a version. I also tried checking the specific previous version and specifying that, but I think all the dependencies

ActiveRecord and using reject method

点点圈 提交于 2020-01-02 10:02:28
问题 I have a model that fetches all the games from a particular city. When I get those games I want to filter them and I would like to use the reject method, but I'm running into an error I'm trying to understand. # STEP 1 - Model class Matches < ActiveRecord::Base def self.total_losses(cities) reject{ |a| cities.include?(a.winner) }.count end end # STEP 2 - Controller @games = Matches.find_matches_by("Toronto") # GOOD! - Returns ActiveRecord::Relation # STEP 3 - View cities = ["Toronto", "NYC"]

How do you customize transliterations in a Rails 3 app?

爱⌒轻易说出口 提交于 2020-01-02 09:58:51
问题 Ultimately, I would like to use Inflector.parameterize to create slugs for article heading that have a bunch of unicode chars in them (e.g. "ḤellẒ no" => "hellz-no"). According to http://api.rubyonrails.org/classes/ActiveSupport/Inflector.html#method-i-transliterate it says to put them in the locales/en.yml file. # Store the transliterations in locales/en.yml i18n: transliterate: rule: Ḥ: "h" Ẓ: "z" I tried that but the following does not work: "ḤellẒ no".parameterize # => "ell-no" However,

Rails 3 Routing Resources with Variable Namespace

谁说我不能喝 提交于 2020-01-02 09:31:50
问题 Is it possible to have a variable namespace? I have restful resources like the following: resources :articles resources :persons But I need to scope these inside a variable namespace, such that it responds to URLs of the form: ':edition/:controller/:action/:id' for example: /foobar/article/edit/123 or /bazbam/person/edit/345 for each of the resources. Is this possible with the resources method, or must I hand-craft these? I will not know the possible values for :edition ahead of time; these

Finding unique records, ordered by field in association, with PostgreSQL and Rails 3?

混江龙づ霸主 提交于 2020-01-02 08:56:30
问题 UPDATE : So thanks to @Erwin Brandstetter, I now have this: def self.unique_users_by_company(company) users = User.arel_table cards = Card.arel_table users_columns = User.column_names.map { |col| users[col.to_sym] } cards_condition = cards[:company_id].eq(company.id). and(cards[:user_id].eq(users[:id])) User.joins(:cards).where(cards_condition).group(users_columns). order('min(cards.created_at)') end ... which seems to do exactly what I want. There are two shortcomings that I would still like

Why do my changes to model instances not get saved sometimes in Rails 3?

爱⌒轻易说出口 提交于 2020-01-02 08:55:10
问题 I have a model named Post and I created two methods within the model that make changes to fields. The first method's changes get persisted when a save is called. The second method's changes do not get saved. I have noticed this behavior before in other models and I think I'm missing some basic knowledge on how models work. Any help on this would be greatly appreciated! class Post < ActiveRecord::Base def publish(user) # These changes get saved reviewed_by = user touch(:reviewed_at) active =

How to override Rails' default migration generator template

徘徊边缘 提交于 2020-01-02 08:22:30
问题 I need to override these migration templates: https://github.com/rails/rails/blob/e20dd73df42d63b206d221e2258cc6dc7b1e6068/activerecord/lib/rails/generators/active_record/migration/templates/migration.rb and https://github.com/rails/rails/blob/e20dd73df42d63b206d221e2258cc6dc7b1e6068/activerecord/lib/rails/generators/active_record/migration/templates/create_table_migration.rb inside my rails application so that they pick up the template from rails application instead of the gem itself. I've