Is it possible to put variables in my query not using string interpolation? Posted: 18 May 2016 06:16 AM PDT Ok so I have an SQL request using string interpolation and running perfectly : ActiveRecord::Base.connection.execute("UPDATE my_table SET location = ST_SetSRID(ST_MakePoint('#{my_table.longitude}'::numeric, '#{my_table.latitude}'::numeric), 4326)::geography WHERE id=#{id}") What I want to do is using SQL variables instead of string interpolation (for security reasons (SQL injections)) but I have been into some troubles with my query : ActiveRecord::Base.connection.execute("UPDATE my_table SET location = ST_SetSRID(ST_MakePoint(':longitude'::numeric, ':latitude'::numeric), 4326)::geography WHERE id=#{id}", longitude: my_table.longitude, latitude: my_table.latitude) The error I get is : PG::InvalidTextRepresentation: ERROR: invalid input syntax for type numeric: ":longitude" (ActiveRecord::StatementInvalid) Is there a way to use SQL variables properly in the last query ? |
Translating interface of TinyMCE Posted: 18 May 2016 06:03 AM PDT Options language in tab navigation doesn't change. I use it: tinymce-rails-langs In _form.html.haml , where I use tinymce add: = f.text_area :content, :class => "tinymce", :rows => 40, :cols => 120 ... ... :javascript tinyMCE.init({ selector: 'textarea.content' language: 'pl' }); Where is problem, why doesn't it change language? |
Dokku on DigitalOcean Posted: 18 May 2016 05:35 AM PDT I have just deployed my rails application onto Dokku on DigitalOcean. I would like to 1. Enable SSL support for the app 2. By default,the application is running on some port. So now I'm able to access the application by using [DROPLET_IP]:[PORT] but not able to directly access it with [DROPLET_IP] . I have my DNS over Cloudflare. I want it to access the application over subdomain.mydomain.com . Although, I configured my subdomain to point out to point out to DROPLET_IP , but even that subdomain.mydomain.com:PORT isn't working! While deploying and restarting, I get VHOST support disabled. Skipping domains setup I'm not sure if this has anything related to this. Just thought, this may help. Any help is appreciated! Thanks. |
Rails: should 'double' user class (with polymorphic assoc) be created in model or controller? Posted: 18 May 2016 05:33 AM PDT I have a user class with an inseparable polymorphic association (depending on a user type). Every time a new user is created the corresponding user type model must also be created. User can be created not only via regular registration but also using omniauth (facebook, google). The question is: should I create user and user type in each action or add custom create function in user model, pass type of user and some parameters and create both user and user type there? Here is create action from my registration controller: def create if params[:type] == 'employee' @user_type = Employee.new sign_up_params[:user_type_attributes] elsif params[:type] == "customer" @user_type = Customer.new sign_up_params[:user_type_attributes] elsif params[:type] == "owner" @user_type = Owner.new sign_up_params[:user_type_attributes] else flash[:notice]="Invalid parameter" redirect_to :controller=>'welcome', :action=>'register_choice' return end build_resource(sign_up_params) if resource.valid? && @user_type.valid? ActiveRecord::Base.transaction do super do @user_type.save resource.user_type = @user_type if !@user_type.persisted? || !resource.persisted? clean_up_passwords resource set_minimum_password_length flash[:alert]="Error" raise ActiveRecord::Rollback end end end else #TODO error messages clean_up_passwords resource set_minimum_password_length flash[:alert]="Error" respond_with resource end end |
How to upload videos from ckeditor in rails angulajs? Posted: 18 May 2016 05:31 AM PDT I am trying to use ckeditor to upload and play the video in my rails project. Angular using for front-hand. |
Execute a short background task in a rails controller Posted: 18 May 2016 05:45 AM PDT Let's take an example : class UsersController def create User.create(...) PushService.push('you have a new friend') # Can take 1/2 seconds end end I want to execute a short task (Pushing some users) in the controller. I don't do it synchronously because it can increase the response time, but using Resque , Sidekiq or DelayJob seems exaggerated to me. What would be the consequences of using a simple Thread , is that a good practice to use it in a controller? Do you have other alternatives? |
Responding to page updates with Turbolinks 5 Posted: 18 May 2016 05:29 AM PDT I use Turbolinks 5 with Rails 5. New elements injected with AJAX need to be initialized to be recognized by jQuery, but I don't know how to accomplish this. The documentation refers to the use of MutationObserver, but I don't understand when, where and how to use it. How would I implement MutationObserver to work with Turbolinks when updating the page? |
How to update User role using rolify gem Posted: 18 May 2016 05:24 AM PDT Is there any way to update an User role after adding any role. user.rb has_many :invitations, :class_name => self.to_s, :as => :invited_by belongs_to :invited_by, :polymorphic => true role.rb has_and_belongs_to_many :users, :join_table => :users_roles belongs_to :resource, :polymorphic => true |
I want to implement Regular Expression with ruby String.scan Posted: 18 May 2016 05:12 AM PDT Given a multi-line string containing prices in different formats anywhere in the multi-line string, I want to implement a Regular Expression that can run with the String.scan method to extract all the prices in an array. The string looks like: "this is some prices $500.00, $5,000.00, US$50.00, R$500,000.00, US$1.5M,$550K something is better price for the product J$50.00" And output looks like [500, 5000, 50, 500000, 1500000, 550000, 50] Please tell if anyone have any query. let me know if I am wrong. Actually I am new with ruby and regular expression. Thanks in advance for any solution and suggestion. |
Rails - how to cache more assets Posted: 18 May 2016 05:09 AM PDT I try to make my website as fast as possible. So i also want to cache as much as possible. Now i got this: so i tried to force cache the css first: <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true, :cache => true %> Still its not cached, i got green circle i need grey one. How to force browser to cache application css file. |
Add the name of a model to a string in Rails Posted: 18 May 2016 05:32 AM PDT I wanna achieve the following to display in rails app: Product instance => "product" ProductCustomer instance => "product customer" so I could do <%= form_for([commentable, Comment.new]) do |f| %> <%= f.text_field :body, class: "form-control", id: "comment-text-area-#{commentable.id}", placeholder: "Ask something about the #{commentable.class.name.split(/(?=[A-Z])/).join(' ').downcase }" %> ...... <% end %> At the moment I'm using the following which works in all cases: p = Product.new p.class.name.split(/(?=[A-Z])/).join(' ').downcase pc = ProductCustomer.new pc.class.name.split(/(?=[A-Z])/).join(' ').downcase My problem is that it seems to be too complex. I guess there should be a better way. Any ideas? |
Sorting hash in ruby Posted: 18 May 2016 05:11 AM PDT sorter.sort_by{|name, user_id| user_id} is not working. Even though the hash map sorter is sorted it prints unsorted hash. I have append the name and user_id with the required condition in the hash map: require 'json' class Numeric def to_rad self * Math::PI / 180 end end def distance( lat2, lon2) lat1=12.9611159 lon1=77.6362214 dLat = (lat2-lat1).to_rad; dLon = (lon2-lon1).to_rad; a = Math.sin(dLat/2) * Math.sin(dLat/2) + Math.cos(lat1.to_rad) * Math.cos(lat2.to_rad) * Math.sin(dLon/2) * Math.sin(dLon/2); c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); d = 6371 * c; return d end file= File.read('customers.json') data_hash= JSON.parse( file) sorter = Hash.new data_hash["customers"].each do |user| latitude=user["latitude"].to_f longitude=user["longitude"].to_f $count=0 if (distance(latitude,longitude).to_f < 100.00) name = user["name"] user_id=user["user_id"] sorter[name]=user_id # print name," ",user_id # print "\n" end # end sorter.sort_by{|name, user_id| user_id} print sorter |
Rails query with includes for has_many and belongs to association Posted: 18 May 2016 05:43 AM PDT I have two model with following associations class Application < ActiveRecord::Base belongs_to :registrations end class Registration < ActiveRecord::Base has_many :applications, :dependent => :destroy end Now I am trying to do a query like this below @applications = Application.includes(:registration).where("registration.stdniveau = ? AND uni_id = ? AND offer_sent = ? AND (offer_accepted =? OR offer_accepted =?)", 2, @uni.id, 1, nil, 1).references(:registration) I also tried this @applications = Application.includes(:registrations).where("registrations.stdniveau = ? AND uni_id = ? AND offer_sent = ? AND (offer_accepted =? OR offer_accepted =?)", 2, @uni.id, 1, nil, 1).references(:registrations) But both query gives me unreadable error. I don't understand what am I missing here? |
Puma and Nginx 502 Bad Gateway error (Ubuntu Server 14.04) Posted: 18 May 2016 06:16 AM PDT I need to deploy my rails application,So I have followed all step from here, https://www.digitalocean.com/community/tutorials/how-to-deploy-a-rails-app-with-puma-and-nginx-on-ubuntu-14-04 But end of the tutorial, I get this error --> "502 Bad Gateway" puma-manager --> I checked it works correctly paths ---> I have checked three times Nginx error.log output message: 2016/05/18 14:22:21 [crit] 1099#0: *7 connect() to unix:/home/deploy /hotel-automata/shared/sockets/puma.sock failed (2: No such file or directory) while connecting to upstream, client: 192.168.2.105, server: localhost, request: "GET /favicon.ico HTTP/1.1", upstream: "http://unix:/home/deploy/hotel-automata/shared/sockets/puma.sock:/500.html", host: "192.168.2.170" OS -> Vmware Player, Bridged Network Ubuntu Server 14.0.4 Ruby Version: 2.3.1 Rails Version: 4.2.5.2 This is my nginx config contents of /etc/nginx/sites-available/default upstream app { # Path to Puma SOCK file, as defined previously server unix:/home/deploy/hotel-automata/shared/sockets/puma.sock fail_timeout=0; } server { listen 80; server_name localhost; root /home/deploy/hotel-automata/public; try_files $uri/index.html $uri @app; location @app { proxy_pass http://app; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; } error_page 500 502 503 504 /500.html; client_max_body_size 4G; keepalive_timeout 10; } |
NoMethodError (undefined method `val' for #<Arel::Nodes::BindParam:0x007fe5554268b8>): app/controllers/posts_controller.rb:10:in `new' Posted: 18 May 2016 04:36 AM PDT I am new to rails. Everything is working fine locally but after deploying on heroku its giving me the above error. Here is the posts_controllers action: def new @post = current_user.posts.build end and here is the schema.rb file content: ActiveRecord::Schema.define(version: 20160516214156) do create_table "comments", force: :cascade do |t| t.text "comment" t.integer "post_id" t.integer "user_id" t.datetime "created_at", null: false t.datetime "updated_at", null: false end add_index "comments", ["post_id"], name: "index_comments_on_post_id" add_index "comments", ["user_id"], name: "index_comments_on_user_id" create_table "posts", force: :cascade do |t| t.text "description" t.datetime "created_at", null: false t.datetime "updated_at", null: false t.string "image_file_name" t.string "image_content_type" t.integer "image_file_size" t.datetime "image_updated_at" t.integer "user_id" end create_table "users", force: :cascade do |t| t.string "email", default: "", null: false t.string "encrypted_password", default: "", null: false t.string "reset_password_token" t.datetime "reset_password_sent_at" t.datetime "remember_created_at" t.integer "sign_in_count", default: 0, null: false t.datetime "current_sign_in_at" t.datetime "last_sign_in_at" t.string "current_sign_in_ip" t.string "last_sign_in_ip" t.datetime "created_at", null: false t.datetime "updated_at", null: false end add_index "users", ["email"], name: "index_users_on_email", unique: true add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true end |
rails method undefined job_apps Posted: 18 May 2016 04:32 AM PDT I get and error undefined method 'job_apps' (tried with single form 'job_app' too) def accept @job_apps = job_apps.find(params[:id]) @job_apps.update_attribute(status: :accept) end def refuse @job_apps = job_apps.find(params[:id]) @job_apps.update_attribute(:status,2) end routes: get 'accept' => 'job_apps#accept' post 'accept' => 'job_apps#accept' Tried: def accept @job_apps = @user.job_app @job_apps.update_attribute(status: :accept) end I had similar trouble for calling the job_app in the same view (to see job_app.status as it is table joined with users on user_id) but on stack overflow someone helped me with this (view file): <th><%= user.job_app.status %></th> |
UserPolicy for Index Posted: 18 May 2016 05:18 AM PDT I am trying to create a policy so that only admins can acces a page. I've already managed to get pundit to work in another controller, but for some reason this policy wont work. I've created a controller: users_controller.rb which is as follows: def index @user = current_user authorize @user end end I've created a Policy user_policy.rb which is: def initialize(current_user, record) @user = current_user @record = record end def index? @user.admin? end end Any idea's what's going wrong? |
Routes to update a nested form Posted: 18 May 2016 04:55 AM PDT I'm new in RoR, and I'm trying to practice building a web app. I have a classic app with User who have Post. An other model Online is used to put the post on a common wall, and it's associated with a nested form Orders which represents pieces available. So now, I'm trying to update that nested form (orders) with a button in my post show view. But it return me an error "No route matches [POST]" while I write a PUT. So why he thinks that I want to make a new order (POST) ? And how can I change that ? My code : routes : Rails.application.routes.draw do get 'profiles/show' mount RailsAdmin::Engine => '/admin', as: 'rails_admin' devise_for :users, :controllers => { registrations: 'registrations' } resources :posts do resources :comments resources :onlines do resources :orders end end get ':pseudo', to: 'profiles#show', as: :profile get ':pseudo/edit', to: 'profiles#edit', as: :edit_profile patch ':pseudo/edit', to: 'profiles#update', as: :update_profile put 'online/:id/taked', to: 'onlines#taked', as: :taked_online root 'posts#index' Views/posts/show : <div class="col-md-9"> <h3>Orders :</h3> <div id="Orders"> <ul> <%- @post.onlines.each do |online| %> <%- online.orders.each do |order| %> <%- if order.taked == false %> <li> <%= link_to 'Take', taked_online_path(online), method: :update, class: "btn btn-warning"%> </li> <%end%> <%end%> <%end%> </ul> </div> </div> and my Online controller : before_action :set_post before_action :owned_online, only: [:new, :update] before_action :set_online, except: [:taked] before_action :set_unline, only: [:taked] def new @online = current_user.onlines.build @online.post_id = @post.id @online.user_id = current_user.id end def edit end def taked @online.orders.update(taked: true, taked_at: Time.zone.now, taked_by: current_user) end def create if Online.where(post_id: params[:post_id]).any? @online = Online.where(post_id: params[:post_id]).last.update_attributes(push: false) end @online = @post.onlines.create(online_params) if @online.save if @online.portion <= 0 @online.update(push: false) flash[:success] = 'Veuillez indiquer le nombre de parts disponibles ' redirect_to root_path else @online.update(pushed_at: Time.zone.now) @online.update(push: true) flash[:success] = 'Votre post est en ligne !' redirect_to root_path end else render 'new' end end def update if @onlines.update(online_params) if @online.push == false if @online.portion <= 0 @online.update(push: false) flash[:success] = 'Veuillez indiquer le nombre de parts disponibles ' redirect_to root_path else @online.update(push: true) flash[:success] = 'Votre post a bien été pushé !' redirect_to root_path end end else @user.errors.full_messages flash[:error] = @user.errors.full_messages render :edit end end private def online_params params.require(:online).permit(:user_id, :post_id, :prix, :portion, :push, :pushed_at, orders_attributes: [:id, :taked, :taked_at, :taked_by, :validated_at, :validated_by, :_destroy]) end def owned_online @post = Post.find(params[:post_id]) unless current_user == @post.user flash[:alert] = "That post doesn't belong to you!" redirect_to :back end end def set_post @post = Post.find_by(params[:post_id]) end def set_online @post = Post.find(params[:post_id]) @online = Online.find_by(params[:id]) end def set_unline @online = Online.find_by(params[:id]) end end Models : Post : class Post < ActiveRecord::Base belongs_to :user has_many :onlines, dependent: :destroy scope :push_posts, lambda { joins(:onlines).merge(Online.push) } has_many :ingredients, dependent: :destroy accepts_nested_attributes_for :ingredients, reject_if: :all_blank, allow_destroy: true has_many :comments validates :image, presence: true has_attached_file :image, styles: { medium: "300x300#"}, default_url: "/images/:style/missing.png" validates_attachment_content_type :image, content_type: /\Aimage\/.*\Z/ end Online: class Online < ActiveRecord::Base belongs_to :post belongs_to :user has_many :orders accepts_nested_attributes_for :orders, allow_destroy: true scope :push, ->{ where(push: true).order("pushed_at DESC") } end & User : class User < ActiveRecord::Base # Include default devise modules. Others available are: # :confirmable, :lockable, :timeoutable and :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable has_many :posts, dependent: :destroy has_many :onlines, dependent: :destroy has_many :comments has_many :orders, dependent: :destroy validates :pseudo, presence: true, length: { minimum: 4, maximum: 16 } has_attached_file :avatar, styles: { medium: '100x100#' } validates_attachment_content_type :avatar, content_type: /\Aimage\/.*\Z/ end Error : Well, so if you have any advices for that, I'll take it !! Thanks |
Trying to archive a specific feedback in Rails 4 Posted: 18 May 2016 06:08 AM PDT I have created a feedback system and am trying to get a specific feedback to archive. I have tried multiple different configurations, but just can't seem to get it to work. I am not receiving an error, and it looks like it is hitting the controller action as I am receiving the notice. However, the boolean won't change in the DB and the particular feedback will not hide. Any help would be appreciated! - I have added an Archive boolean to my table.
- I have created a route for archive.
- I have created the controller action for archive.
Here is my code: **Controller:** def archive_feedback @listing_feedback = ListingFeedback.find(params[:id]) respond_to do |format| format.html { redirect_to listing_listing_feedbacks_path, notice: "That feedback has been archived." } format.json { render :index } end end **Routes: (My feedback feature is using nested resources)** resources :listings do member do get 'like' get 'unlike' get 'duplicate' get 'gallery' delete 'gallery' => 'listings#clear_gallery' get 'manage_photos' get 'craigslist' get "add_to_collection" end resources :listing_feedbacks do member do put 'archive_feedback' end end end **Index.html.erb:** <p><%= link_to 'Archive', controller: "listing_feedbacks", action: "archive_feedback", id: listing_feedback.id, archive: :true, method: :put %></p> Also, how would I get the feedback to hide once it has been archived? |
How to update branch_id of user Posted: 18 May 2016 04:02 AM PDT user.rb has_many :user_branches has_many :branches, through: :user_branches branch.rb has_many :user_branches has_many :users, through: :user_branches user_branch.rb belongs_to :branch belongs_to :user Now if User.last.user_branches.take.branch_id 12. How to update branch_id ? |
Capistrano deploy:migrate Posted: 18 May 2016 03:48 AM PDT I don´t have error when I do cap production deploy. the migration is successfull but is not in database. deploy:migrating 01 $HOME/.rbenv/bin/rbenv exec bundle exec rake db:migrate 01 == 20160506075320 DeviseCreateUsuarios: migrating ====================… 01 -- create_table(:usuarios) 01 -> 0.0038s 01 -- add_index(:usuarios, :email, {:unique=>true}) 01 -> 0.0008s 01 -- add_index(:usuarios, :reset_password_token, {:unique=>true}) 01 -> 0.0008s 01 == 20160506075320 DeviseCreateUsuarios: migrated (0.0054s) ===========… 01 01 == 20160511002957 AddColumnUidToUsuarios: migrating ==================… 01 -- add_column(:usuarios, :provider, :string) 01 -> 0.0006s 01 -- add_column(:usuarios, :uid, :string) 01 -> 0.0003s 01 == 20160511002957 AddColumnUidToUsuarios: migrated (0.0010s) =========… 01 my production.rb set :stage, :production server 'myserver.com', user: 'deploy', roles: %w{web app db} |
Ruby query Error Posted: 18 May 2016 05:37 AM PDT i have a user model and a location model . I want to point all the users to the first ocurrence of their location in the location table as shown User user_id name location_id 1 tim 1 2 adam 2 3 Joy 3 Location location_id name 1 NewYork 2 NewYork 3 NewYork Expected Ouput: User user_id name location_id 1 tim 1 2 adam 1 3 Joy 1 I tried to run this query but it isnt working: User.joins(:location).update_all("location_id =(select id from locations as l2 where l2.name = locations.name limit 1)") Error: ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: invalid reference to FROM-clause entry for table "locations" LINE 1: ... =(select id from locations as l2 where l2.name = locations.... ^ HINT: Perhaps you meant to reference the table alias "l2". Any solution? |
lock('WITH (NOLOCK)') Breaks SQL Query Cache in Ruby On Rails Posted: 18 May 2016 03:41 AM PDT Running a rails 4 application with an MSSQL DB. I am trying to add a nolock hint to my query, using lock('WITH (NOLOCK)') but this causes the record to be reloaded explicitly. I want to still make use of the SQL query cache and add the nolock hint. Is there any way I can do this? |
Create Nested Build for object rails Posted: 18 May 2016 04:13 AM PDT My JSON API is like below, { "schedule_id": "1", "latitude" : 17.4327, "longitude" : 78.4302, "device_id": "123test", "audit_compliances":[ { "value": "Yes", "score": 10, "remarks": "some remarks", "private_remarks": "some remarks", "check_point_id": 1, "audit_compliance_documents":[{ "score": 10, "remarks": "some remarks", }] }] i have a relations for that DB i want to save all this records at once so i want to initialize the object with details and build inner objects along with that. Started building like this but how can i build inner build for documents. submission = Submission.new(audit_schedule_id: params[:schedule_id], latitude: params[:latitude], longitude: params[:longitude], device_id: params[:device_id]) params[:audit_compliances].each do |audit_compliance| submission.audit_compliances.build( value: audit_compliance[:value], score: audit_compliance[:score], remarks: audit_compliance[:remarks], private_remarks: audit_compliance[:private_remarks], check_point_id: audit_compliance[:check_point_id]) end |
Rails server no source of timezone data could be found Posted: 18 May 2016 03:19 AM PDT I am working on a project team with ruby on rails, the project was created on MAC OSX and I use windows. When I try to start the server with rails server , I have this error : Rails server no source of timezone data could be found I do a bundle install and after a `gem install tzinfo-data, then I have the same error again. How can I solve this problem and launch my server ? |
Haversine formula in ruby Posted: 18 May 2016 03:38 AM PDT I need to calculate distance between the latitudes and longitudes obtained from json with the lats and longs inside distance method I am getting error distance': undefined method -' for "12.986375":String (NoMethodError) require 'json' class Numeric def to_rad self * Math::PI / 180 end end def distance( lat2, lon2) lat1=12.9611159 lon1=77.6362214 dLat = (lat2-lat1).to_rad; dLon = (lon2-lon1).to_rad; a = Math.sin(dLat/2) * Math.sin(dLat/2) + Math.cos(lat1.to_rad) * Math.cos(lat2.to_rad) * Math.sin(dLon/2) * Math.sin(dLon/2); c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); d = 6371 * c; puts d end file= File.read('customers.json') data_hash= JSON.parse( file) data_hash["customers"].each do |user| latitude=user["latitude"] longitude=user["longitude"] distance(latitude,longitude) end Below is my json file from which lats and longs are taken. {"customers" :[ {"latitude": "12.986375", "user_id": "12", "name": "Chris", "longitude": "77.043701"}, {"latitude": "11.92893", "user_id": "1", "name": "Alice", "longitude": "78.27699"}, ] } |
Ruby on rails active record issue Posted: 18 May 2016 03:10 AM PDT There are 2 Api : 1) 1st api I am finding Order.find 1 . 2) 2nd api I am finding Order.find 1 and updating result as success. I am not getting result as success which I updated in 2nd api. Both are same object? How will I get that updated record in my first api. I have put the sleep and reload in 1st api. The record is updated but still it is giving as null. Please let me know how can I implement it. Thanks in advance .. |
File not found ".permissions_check.47195105728920.30272.773108" Rails Action caching Posted: 18 May 2016 03:01 AM PDT In our websites we use action caching on de homepage and some show pages. With this gem https://github.com/rails/actionpack-action_caching. This works fine, but since they are websites with thousands of users we use Sentry to log our exceptions and occasionally we come across this one: Errno::ENOENTfileutils.rb in initialize at line 1156 errorNo such file or directory @ utime_internal - /var/www/<anonymised-data>/releases/20160511070255/tmp/cache/0A8/601/.permissions_check.47195105728920.30272.773108 It doesn't happen often. My best guess is because we have a 60 second expiry time is that there is a problem when 2 requests come in at the same time and request a cached page, the first request already deletes the cache because it was expired but the other request already requested a cached version before that? Anyone ever came across such an error? The sites (10 of them) each generate 3/4 requests per second. |
Disable X-Frame-Options only for a URL in rails 4 Posted: 18 May 2016 02:59 AM PDT The idea is only allow a URL lo load a Rails 4 inside a container (iframe/webview) Where would be the best place to put that logic? My first option is inside the ApplicationController as a before_filter? class ApplicationController < ActionController::Base before_filter :set_xframe_options private def set_xframe_options response.headers['X-Frame-Options'] = 'SAMEORIGIN' unless some_condition? end |
Add SAN or Local disk to already provisioned Server in Softlayer Posted: 18 May 2016 02:50 AM PDT I am new to the softlayer rest APIs. We have a requirement where user will be allowed to add a additional SAN or Local Disk to the existing provisioned server in softlayer. For that I was referring to the REST API guide Our project is build on Ruby on Rails and we are using softlayer_api gem and so I was looking at the api ruby doc. But none of these links helped me. Are there any ruby examples for adding a disk ? |
No comments:
Post a Comment