mardi 5 janvier 2016

Custom beginning and end of quarter methods

I saw the source code on how to get the quarters from the Date method in rails, but I have this feature where something can recur quarterly (or every 3months) but it does not follow the yearly quarter instead the user can define what month the cycle will start. Would it be possible for me to create my own method where it sort of works the same way with the Date methods on handling the quarter dates?

How to set a specific Number as Next ID and Its Continuation to use as Primary Key on Creation of Next Record On wards in PL-SQL in my Rails-4 App?

If my Question title is not clear, Let me details it more: In my rails application, in local(development) I am using PL-SQL as my databse, and there is a Customer table where the Primary ID starts from 1,2,3.......so on. Till I start using the same database in Local(development) & Production there was no problem in creating customers, so after I started running Local(development) & Production in parallel with same DB many of the time customer creations fails as ID's trying to create as Duplicate. So how can I set in my Local/Production to change the next Index to start with for the ID into another number to avoid this conflict. ?

Eg: I want to continue using(1,2.....etc) the ID in Local & in production I want to set the next Id from 50000 on wards and continuation.

lundi 4 janvier 2016

Edit option in People plugin Redmine

I have installed Redmine People plugin.In this plugin users are allowed to edit thier own profile.They can also upload thier pics.I dont want users to upload thier pic instead I only want only the admin to upload the pics of Redmine users.How can I do this.?Please help

ActiveScaffold show relational value

I have a simple table being shown in ActiveScaffold. The table has three fields: an ID, a description, and a second ID which is a foreign key to another table. In the ActiveScaffold list view, I want to show the 'name' field from the related table rather than the table value (an unhelpful ID number).

I have looked over the ActiveScaffold basic documentation, FAQ, and forum (as well as doing an SO search) with no luck. The AS API docs describe a boatload of functionality associated with ActiveRecord associations, but appear to have nothing on the basics of setting up these relationships.

How can I accomplish this?

dimanche 3 janvier 2016

Rack MiniProfiler not capturing sql queries in My Rails app

In our Project we have a lot of ActiveRecord models, we use Postgres as our DB Server and also MongoDB with mongoid 2.2 gem. I need to improve/optimize our project to reduce the number of SQL queries being executed I chose rack-mini-profiler gem to profile my app for SQL queries. initially I did

gem "rack-mini-profiler"

but didn't work giving the following error

uninitialized constant Mongo::Server (NameError)

then I just fixed the version to 0.9.7 and it worked without any problem, but the sql queries in log were Zero to Minimal. The queries I am trying to profile are of Postgres and I can see them in the my terminal, but not in miniprofiler on my view page.

only when user sign_ins/sign_outs the update query shows up some times and nothing else shows up.

I also tried ?pp=full-backtrace with no use.

I also have caching enabled via Dalli gem and memcached and I also tried setting miniprofiler store to MemStore.

miniprofiler log

  • Ruby: 1.9.3p550
  • Rails: 3.1.10
  • pg: 0.11.0
  • mongoid: 2.2
  • OS: Ubuntu 14.04 x86_64

Getting undefined method `created_at'

Why is this so? Is there any chance I can get created date of my object?

index.html.erb

<td><%= link_to 'Show', article_date(article) %></td>

articles_helper.rb

module ArticlesHelper
  def article_date(article)
    published_at = article.created_at
    options = {
      year: published_at.strftime('%Y'),
      month: published_at.strftime('%m'),
      day: published_at.strftime('%d'),
      id: article.id
    }
    article_date(options)
  end
end

Heroku - "The page you were looking for doesn't exist." though it exists on localhost:3000

I tried almost every solution from the previous questions, but there is no which applies to my problem. Basically, my app works on localhost:3000 but does not on Heroku. I generated scaffold User name:string email:string. Git commited and pushed to Heroku, it states that everythings went ok. However, on the page http://ift.tt/1O3RTce I get 404.

heroku logs:

heroku[router]: at=info method=GET path="/favicon.ico" host=appofmine.herokuapp.com request_id=e39fb228-d587-4d18-8395-2405eec3a59d fwd="85.202.153.28" dyno=web.1 connect=2ms service=5ms status=200 bytes=228

routes.rb:

Rails.application.routes.draw do
  resources :users
  root "users#index"
end