Saturday, January 14, 2017

modify syntax highlighting in gedit for ruby/RoR | Fixed issues

Newest questions tagged ruby-on-rails - Stack Overflow

modify syntax highlighting in gedit for ruby/RoR | Fixed issues


modify syntax highlighting in gedit for ruby/RoR

Posted: 14 Jan 2017 07:00 AM PST

I would like to know how to modify or create a Theme for highlighting syntax for Ruby/RoR?| by that I mean which file or where and how do I create such file or where do I find one? I am curious about that since Gedit is an open software I did not seem to have found any documentation about that.

Thank you for your time. Best regards,

iOS In App Purchase with Rails Backend

Posted: 14 Jan 2017 06:50 AM PST

I'm having some confusions when creating in app purchase strategy for my iOS app. Some background info below;

I have an iOS app and a web app which both will work in subscription model. The backend has been developed in Ruby on Rails.

Currently I'm trying to develop the iOS auto-renewal in app purchase. I came across couple of gems which helps to verify in app purchase receipts (e.g Venice). I get that the whole point of verifying the receipts from the backend rather then the client is to make it secure and to be able to keep a copy of the receipt in your own server.

I can foresee a huge problem as explained below;

A user can create an account using the iOS app and subscribe to the service by paying X dollars monthly using x@x.com apple id. By doing this I will have the record of this user in my backend including the expiry date of his subscription which will enable for me to track if he renewed his subscription or not. The problem arises when this user logs out from the app and creates another user. Since his apple id is still x@x.com and as account email address or id doesn't matter at all when making a purchase from apple, the expiry date will still be a month ahead since he just subscribed with his previous account the new user will be identified as an already paid customer. Boom! now his friend can login with this account using the web app and enjoy it without paying a quid.

If this makes sense for you, there must be a solution for this hack. I know that Netflix uses Apple's IAP, Spotify used for a very long time.

Also gems like Venice, they don't put a thorough documentation on their github page therefore I don't know if this problem is solved by them out of the box. Just wanted to check with you guys and I'm sure many of you thought about this.

How to wrap my Ruby on Rails partials in a Tabbed Boostrap Signup Form

Posted: 14 Jan 2017 07:50 AM PST

I have used MTI (Multiple Table Inheritance) structures to create different SignUp Forms for my users such that I have 3 different partials called _company.html.erb, _individual.html.erb, and _admin.html.erb, since they have different details to be used for signing up into the app am working on. However, I want to render each partial such that I could achieve a TabbedForm based on Bootstrap.

For more clarity, I like to achieve something like this picture below:

enter image description here

Here is what I have done:

SignUp View

<div class="container">    <div class="row">      <div class="col-md-6 col-md-offset-3">        <div class="panel panel-login">          <div class="panel-heading">            <div class="row">              <div class="col-xs-6">                <a href="#" class="active" id="login-form-link">Login</a>              </div>              <div class="col-xs-6">                <a href="#" id="register-form-link">Register</a>              </div>            </div>            <hr>          </div>          <div class="panel-body">            <div class="row">              <div class="col-lg-12">                <%=    render 'companies/form' %>                <%=    render 'individuals/form' %>              </div>            </div>          </div>        </div>      </div>    </div>  </div>  

One of the Partials rendered in the Signup View above _form.html.erb

<%= simple_form_for(Company.new) do |f| %>    <%= f.error_notification %>      <div class="form-inputs">      <%= f.input :company_name, label: "Company Name", placeholder: 'Company Name' %>      <%= f.input :company_url, label: "Company URL", placeholder: 'Company URL' %>      <%= f.input :country, label: "Country", placeholder: 'Country' %>      <%= f.input :contact_person, label: "Contact Person", placeholder: 'Contact Person' %>      <%= f.input :phone_number, label: "Phone Number", placeholder: 'Phone Number' %>      <%= f.input :email, required: true, autofocus: true %>      <%= f.input :password, required: true, hint: ("#{@minimum_password_length} characters minimum" if @minimum_password_length) %>      <%= f.input :password_confirmation, required: true %>    </div>      <div class="form-actions">      <%= f.button :submit %>    </div>  <% end %>  

How do I wrap my Partials in Bootstrap Tabs such that I can have a TabbedForm like the provided picture above?

Rails - raw() removing FORM from content field data

Posted: 14 Jan 2017 06:40 AM PST

I have a text field that stores page content created with a WYSIWYG HTML Editor.

Text field (content):

<form accept-charset="UTF-8" action="/myaction" method="post">  <input name="myaction[product]" type="hidden" value="Other" />   <input name="myaction[product]" type="hidden" value="Car" />   <input class="btn btn-primary" type="submit" value="Get a Car"/>  </form>  

Show page

raw(@page.content)  

The form does not seem to display or show the bootstrap form and button. It seems to be getting removed. What can I do to get the form to display?

What differences exist between .update_one(:$set=>params) and .update_one(params)

Posted: 14 Jan 2017 07:03 AM PST

What differences exist between .update_one(:$set=>params) and .update_one(params)?

What would happen if I used .update_one(:$set=>params) instead of .update_one(params) in the last line of the code below?

def update(params)     @number=params[:number].to_i    @first_name=params[:first_name]     @last_name=params[:last_name]     @secs=params[:secs].to_i    @group=params[:group]    @gender=params[:gender]      params.slice!(:number, :first_name, :last_name, :gender, :group, :secs)      self.class.collection     .find(_id: BSON::ObjectId.from_string(@id))     .update_one(params)  end  

Adding an icon to simple_form submit button

Posted: 14 Jan 2017 06:15 AM PST

I would like to replace the text for the simple_form submit button with an icon.

This is what I have so far:

<div class="small-3 columns">    <%= f.submit class: 'button postfix' do %><i class="fa fa-paper-plane"></i><% end %>  </div>  

Feedjira not adding content and author

Posted: 14 Jan 2017 06:12 AM PST

I've just started on Rails again and have recently followed the Sitepoint guide to building an RSS Feed app. I followed the instructions verbatim, but am getting the error undefined method 'html_safe' for nil:NilClass. I've looked into the database and it seems Feedjira is not parsing the content or author attributes into the database.

After a quick google, I found the following issues on the Github page #178 and #176 dated back from August 13, but given the significant issue this causes I'm surprised there's not on it. It may be an error in my code which can be found here but I've checked and don't think it is.

Does anyone know of anything I'm doing wrong, and if I just need to heed the advice from the issues, can anyone help me with implementing it as I'm not sure how to?

Different output in chrome console and rails log

Posted: 14 Jan 2017 06:25 AM PST

I am trying to add data through cross platform form in rails. Data are also being added but the response in my browser is always an error with some json object.

Output in rails log:-

Started POST "/batches.json" for 127.0.0.1 at 2017-01-14 19:33:34 +0545  Processing by BatchesController#create as JSON    Parameters: {"batch"=>{"name"=>"shitalluitel", "course_id"=>"9", "start_date"=>"2016-12-12", "end_date"=>"2016-12-14", "batch_status"=>"1"}}    User Load (0.5ms)  SELECT  "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT $2  [["id", 1], ["LIMIT", 1]]     (0.2ms)  BEGIN    SQL (0.5ms)  UPDATE "users" SET "current_sign_in_at" = $1, "last_sign_in_at" = $2, "sign_in_count" = $3, "updated_at" = $4 WHERE "users"."id" = $5  [["current_sign_in_at", 2017-01-14 13:48:34 UTC], ["last_sign_in_at", 2017-01-14 13:47:54 UTC], ["sign_in_count", 77], ["updated_at", 2017-01-14 13:48:34 UTC], ["id", 1]]     (15.6ms)  COMMIT     (0.2ms)  BEGIN    Course Load (0.2ms)  SELECT  "courses".* FROM "courses" WHERE "courses"."id" = $1 LIMIT $2  [["id", 9], ["LIMIT", 1]]    SQL (1.2ms)  INSERT INTO "batches" ("name", "course_id", "start_date", "end_date", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5, $6) RETURNING "id"  [["name", "shitalluitel"], ["course_id", 9], ["start_date", Mon, 12 Dec 2016], ["end_date", Wed, 14 Dec 2016], ["created_at", 2017-01-14 13:48:34 UTC], ["updated_at", 2017-01-14 13:48:34 UTC]]     (8.7ms)  COMMIT  Entered to true part  Completed 200 OK in 104ms (Views: 0.2ms | ActiveRecord: 36.8ms)  

but in browser it shows as below: -

Object {readyState: 0, responseJSON: undefined, status: 0, statusText: "error"}  test.html?_ijt=m511tgfk5o03pohpjpk2ebuppf:88   Navigated to http://localhost:63342/zeftware/shitalluitel.github.io/test.html?batch%5Bstatus%5D=0  

Code for submitting form is:-

$(document).ready(function () {          $('#submit-button').click(function() {              $.ajax({                  type: "POST",                  url: "http://localhost:3000/batches.json",                  beforeSend: function(xhr) {xhr.setRequestHeader('X-CSRF-Token', $('meta[name="csrf-token"]').attr('content'))},                  xhrFields: {                      withCredentials: true                  },                  dataType: "json",                  data: {                           batch: {                        name: $("#name").val(),                        course_id: $("#course_id").val(),                        start_date: $("#start_date").val(),                        end_date: $("

No comments:

Post a Comment