w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
Rails app with mongoid ... (Mongoid::Errors::NoSessionConfig): No configuration could be found for a session named 'default'
Your mongoid.yml has an error "hosts:" key should be inside of "default:" because it is a required configuration for sessions Please check http://mongoid.org/en/mongoid/docs/installation.html#configuration

Categories : Mongodb

making a new rails project without downloading gems / locking all gem versions in the Gemfile in a new rails project
First, you can create a new rails project without triggering bundler: rails new foo --skip-bundle Next, you'll have to edit the Gemfile and manually set the gem versions to those that you have installed on your machine. Using pessimistic operator ~> is fine. Example: gem 'rails', '~> 4.0.0' Then install the gems on your local machine with bundler: bundle install --local

Categories : Ruby On Rails

Increment NSNumber inside the GCD Block
Pointers inherited from a block are considered "read-only". In order to modify the value you need to prefix it with __block. In your case you cannot prefix value with __block because it's an argument. Even if you could, your GCD block is asynchronous, and would return before your CGD block was called. For what you're trying to do, you need to do something like this: - (void)doSomethingIntensive:(NSNumber *)value complete:(void (^)(NSNumber *result))complete { dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0); dispatch_async(queue, ^{ if (complete) complete(@(value.integerValue + 1)); }); } You would call such a function like this: [doSomethingIntensive:@(1) complete^(NSNumber *result) { NSLog(@"%@", result); }); The general

Categories : Objective C

accessing sub documents on Rails 3 using Mongoid
Solved. Aash Dhariya helped to solve this in the mongoid google groups. I did change reviews_controller.rb: class ReviewsController < ApplicationController def index @product = Product.find(params[:product_id]) @reviews = @product.reviews end end and app/views/reviews/index.html.erb: <h1>Reviews</h1> <% @product = Product.find(params[:product_id]) %> <table> <tr> <th>Content</th> </tr> <% @reviews.each do |review| %> <tr> <td><%= review.content %></td> </tr> <% end %> </table> <br /> Now it's showing the reviews on a separate page! :)

Categories : Mongodb

Rails app with Mongoid not saving on update
you have to pass params you can use update_attributes or update_attributes! @user = User.find(params[:id]) if @user.update_attributes!(params[:user]) ...

Categories : Ruby On Rails

Unusual Rails Mongoid case
Well, instead of making a workaround, why dont we migrate the old ones? First, change both models to embed by replacing has_one with embeds_one and replacing belongs_to with embedded_in. Save the code. Then use your rails console (>> rails console) Then Output.each do |o| if !o.task_id.nil? #change to embedded format t=Task.find(o.task_id) t.output=o t.output.task_id=nil t.save end end

Categories : Ruby On Rails

Vote with Mongoid at Ruby on Rails
Try changing like this Easyblog::Application.routes.draw do resources :posts do resources :comments do match :vote end member do post :mark_archived end end end

Categories : Ruby On Rails

Rails, Mongoid, query: Not returns documents
You're looking in the wrong places. The error is saying there's something wrong with your config/routes.rb file. Rails is not being able to figure out what URL matches the show method in your controller. Apparently rails generate scaffold_controller does not edit the routes.rb, so you'll have to do it by hand and add the following code to it: resources :tipocontenidos There's a great tool to debug Rails routing here: http://guides.rubyonrails.org/routing.html#listing-existing-routes More about routing: http://guides.rubyonrails.org/routing.html

Categories : Ruby On Rails

Mongoid w/ Rails, attr_accessible --> "No method found"
Ok, I have found the problem. First of all, I assume you are using Rails 4. The reason you are getting this error is that attr_protected and attr_accessible have been removed from Rails 4 and placed in their own gem. Rails is now encouraging a new protection model. You can read about this in the README. If you would like to continue using the old behavior, you must include the protected_attributes gem. Hope that helps. EDIT: I've added clarification below since this is likely to be a common problem with users to upgrading to rails 4. If you would like to continue using attr_accessible, i.e. the Rails 3 way, simply add gem protected_attributes to your Gemfile. If you would like to start doing things the Rails 4 way, you must no longer use attr_accessible. Instead, you must move the at

Categories : Ruby On Rails

Rails - Where MongoDB (Mongoid) stores db and logs?
usually the log files should be at /var/log/mongodb.log or try find / -name mongodb.log. usually it keeps data at /data/db. To know more about where does it store data please visit How is the data in a MongoDB database stored on disk?

Categories : Ruby On Rails

Missing keyword error in Oracle anonymous PL/SQL block
You're missing a semi-colon at the end of your cursor: CURSOR employees_in_10_cur IS SELECT * FROM ad_week_table; The error message will always give you the line number of the error occurring. Please always check this and look in that area. For instance; if I change the table so I can run this I get the following: SQL> declare 2 3 cursor employees_in_10_cur is 4 select * 5 from user_tables 6 7 begin 8 for employee_rec in employees_in_10_cur loop 9 dbms_output.put_line ( 10 employee_rec.ad_no || ',' || employee_rec.week_no ); 11 end loop; 12 end; 13 / for employee_rec in employees_in_10_cur loop * ERROR at line 8: ORA-06550: line 8, column 8: PL/SQL: ORA-00905: missing keyword ORA-06550: line

Categories : Oracle

Designing my own private messaging system in Rails 3.1 and Mongoid
There is a tutorial about how to create a messaging system. The url is not longer available. But you can give this a try: http://web.archive.org/web/20100823114059/http://www.novawave.net/public/rails_messaging_tutorial.html

Categories : Ruby On Rails

How to use twitter style follow feature in rails with mongoid 3.0
Check out this book from Rick Copeland: http://www.amazon.com/MongoDB-Applied-Design-Patterns-Copeland/dp/1449340040/ref=sr_1_1?ie=UTF8&qid=1373395463&sr=8-1&keywords=mongodb+design+patterns The book isn't Rails/Ruby/Mongoid specific but the concepts should translate fairly easy for you. Rick is an avid Python guy and strong member of the MongoDB community. In his book there's actually a whole chapter in there dedicated to creating a social follower/following style model. Hope that helps. Edit: This presentation on "Advanced Schema Design" may be of use to you also. I'm going to be doing a blog post on this topic in the near future, but you can get most of the content here form Jared's talk. http://www.slideshare.net/jrosoff/mongodb-advanced-schema-design-inboxes

Categories : Ruby On Rails

Rails FormHelper collection_check_boxes not working with Mongoid collection
The collection methods seem to be a common gotcha in rails, I wrote a blog post about it here http://www.fmhcc.com.au/ruby/rails/using-collection_select-in-rails/ Although it's about collection_select, it applies to checkboxes too. This should be a step in the right direction = form.collection_check_boxes :neighborhoods, Neighborhood, :id, :name Hope this helps.

Categories : Ruby On Rails

Rails and mongoid returning duplicate records for query
Cursors in mongodb are latent by default. This means that if further writes come in while you are processing the cursor then you may or may not see the results of these updates. Baiscally as more data is added or existing data is modified the object may move around the collection which may causes them to appear in the cursor multiple times(the actual behaviour is unspecified). You can use pass mongoid the snapshot option in your query to fix this problem. (You could also use the hint option specifying the '_id' index.)

Categories : Mongodb

How can I get progress bar to increment by one block till end of bar? Visual Basic 2010
Based on your question i have created a sample. Please try this will some times helps you. Please share your code. So that we can help more private void Form1_Load(object sender, EventArgs e) { progressBar1.Minimum = 0; progressBar1.Maximum = 10; // Maximum should be based on your value } private void button1_Click(object sender, EventArgs e) { if (progressBar1.Value < progressBar1.Maximum) { progressBar1.Value += 1; } }

Categories : Vb.Net

Rails/Mongoid accepting nested attributes for models with inheritance
The problem was in the form, it should be user_form.fields_for :cards instead of :health_cards Below is the corrected version = form_for @user do |user_form| = user_form.fields_for :cards, @health_card do |hc_form| = hc_form.text_field :number = user_form.submit 'Next'

Categories : Ruby On Rails

Ruby on Rails Mongoid and Webfaction: Not Authorized For Query (Error 16550)
The userAdminAnyDatabase role doesn't quite do what you might think it does. Here's what the MongoDB docs say about it: Important: Because users with userAdminAnyDatabase and userAdmin have the ability to create and modify permissions in addition to their own level of access, this role is effectively the MongoDB system superuser. However, userAdminAnyDatabase and userAdmin do not explicitly authorize a user for any privileges beyond user administration. Giving the user you created the userAdminAnyDatabase role, actually only allows them to administer the database (create new users, remove users, access system.* collections) but it doesn't actually authorize them to read or write any data. If you want to create a super user who has all admin privileges and can also read and write in

Categories : Ruby On Rails

how to ignore case-sensitiveness and include nested documents when searching on Rails 4 with Mongoid
You can write: def self.search(search) if search any_of({name: /#{search}/i}, {hobby: /#{search}/i}) end end That will give you all objects that include this value, with ignoring case-sensitive. About adding search by date range. Send to your controller an additional value - for example ~ search_to. def index @parents = if params[:search] Parent.search(params[:search], params[:search_to]) # when searching name/hobby, params[:search_to] will be nil else Parent.all end end Your search function: def self.search(search, search_to) if search && search_to where(:born => {'$gte' => Date.parse(search),'$lt' => Date.parse(search_to)}) elsif search any_of({name: /#{search}/i}, {hobby: /#{search}/i}) end end Question 3 - I don

Categories : Search

Rails 4 increment
This is not a good/safe way to maintain profile views. If there are many people viewing you could have race conditions. There is a highly sophisticated gem called 'impressionist'. (https://github.com/charlotte-ruby/impressionist). Use it. You will have access to lot of features like getting unique profile views based on User, or IP, or session hash etc.

Categories : Ruby On Rails

Rails mongoid solr grouping remote ajax data in Select2: Optgroup appearing multiple times when I search for a child
in this code you are creating a parent item per child: $.each(data, function(index, item){ results.push({ text: item.parent, children: [{id: item._id, text:item.title}] }); }); instead, you should group by parent: var hashtable={}; var results=[]; $.each(data, function(index, item){ if (hashtable[item.parent]===undefined) { hashtable[item.parent]={text:item.parent, children:[]}; results.push(hashtable[item.parent]); } hashtable[item.parent].children.push({id:item._id,text:item.title}); });

Categories : Jquery

Increment a title in a rails form
It may not be very elegant, but a counter in the parent view should do it: view: <% index = 1 %> <%= f.fields_for :levels do |builder| %> <%= render 'level_fields', {f: builder, index: index} %> <% index = index + 1 %> <% end %> partial: <%= f.label :title, "Level #{index}"%>

Categories : Ruby On Rails

Problems with "desc" keyword in Rails app gem
desc is a rake method. you can either require 'rake', or remove: remove: require "dotenv/tasks" There doesn't appear to be any reason to do that.

Categories : Ruby On Rails

Why does the Rails increment method doesn't save the changes?
Check it once if params[:vote][:type] == "up" answer = Answer.find_by_id(params[:vote][:id]) answer.to_i.increment(:ups) render text: answer.ups elsif params[:vote][:type] == "down" answer = Answer.find_by_id(params[:vote][:id]) answer.to_i.increment(:downs) render text: answer.downs end

Categories : Ruby On Rails

rmongodb $cond in aggregation framework
It seems rmongodb cannot really handle operators embedded in other operator when aggregating. I faced the same issue when using $substr in $group. Try only one operator in a stage. If it is not possible, I can recommend RMongo package as an alternative. dbAggregate( mongo, "db", '{ $project : { y : 1, x : {$cond : [{ $ne : ['$x', NaN] }, '$x', 0]} } }')

Categories : Misc

Can I set Mongoid query timeout? Mongoid don't kill long time query
Actually, all queries have a timeout by default. You can set a no_timeout option to tell the query to never timeout.Take a look here You can configure the timeout period using a initializer, like this Mongoid.configure do |config| config.master = Mongo::Connection.new( "localhost", 27017, :op_timeout => 3, :connect_timeout => 3 ).db("mongoid_database") end

Categories : Ruby On Rails

How to start another rails project along with the current project on Ubuntu 12.04?
It looks like you started Diaspora two times. First make sure to you have Diaspora and your other projects alongside each other, not nested. ~/Diaspora ~/Projects Then change into your projects folder, get the latest version of Rails and create a new project: cd ~/Projects gem install rails rails new project2 cd project2 bundle install There start your other project first: cd ~/Projects/project2 bundle exec rails server -p 3002 Now in a second shell start Diaspora: cd ~/Diaspora bundle exec rails server -p 3001 Make sure to use bundle exec to avoid any version conflicts between the gems Diaspora uses and the gems your new application uses.

Categories : Ruby On Rails

my defined cond function is not working properly (LISP)
Your parenthesis are not in the correct places. A parenthesis, unless quoted, are the start of a function application. It begins with a variable cond that is not bound. It's not the special form (cond (predicate consequent) (predicate2 consequent2)) since it doesn't start with an open parenthesis. From indentation alone I guess you meant to write: (DEFUN testAL (x) (COND ((ATOM x) 'this-is-an-atom) ((LISTP x) 'this-is-a-list) (T 'this-is-neither))) (testal 'test) ; ==> THIS-IS-AN-ATOM (testal '(a b c)) ; ==> THIS-IS-A-LIST I have removed the extra parenthesis around x since (x) means apply the function x while x means the variable x. With x in a different position like (+ x 3) then + is the function to be applied and x is one of its operands. I chan

Categories : List

Add auto increment with scope to existing column in migration-file rails
First, I must say this is not a good practice, but I will only focus on a solution for your problem: You can always get the organisation's posts count by doing on your PostsController: def create post = Post.new(...) ... post.post_id = Organization.find(organization_id).posts.count + 1 post.save ... end You should not alter the database yourself. Let ActiveRecord take care of it.

Categories : Ruby On Rails

Could I run a Rails Server and type commands to my Rails Project through terminal at the same time?
Depending on your terminal you can use File->new tab, or maj+ctrl+t to pen a new tab. Personally i have one tab for the server, one for the tests using guard, one for the console and one to have an actual shell.

Categories : Ruby On Rails

.htaccess rewrite cond and rule cannot firgure out extra slash at end
This one seems to work fine for me, give it a try: Options +FollowSymLinks -MultiViews RewriteEngine On RewriteBase / # To externally redirect /dir/foo.html to /dir/foo RewriteCond %{THE_REQUEST} ^[A-Z]{3,}s([^.]+).(html|phtml) [NC] RewriteRule ^ %1 [R=301,L] # To internally forward /dir/foo to /dir/foo.html RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}.html -f RewriteRule ^([^/]*)/?$ $1.html [L] # To internally forward /dir/foo to /dir/foo.phtml RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}.phtml -f RewriteRule ^([^/]*)/?$ $1.phtml [L]

Categories : Apache

observers for mongoid with rails-observers rails4
It looks like you need to include the module in each model and set the observers. class ORM include ActiveModel::Observing end # Calls PersonObserver.instance ORM.observers = :person_observer # Calls Cacher.instance and GarbageCollector.instance ORM.observers = :cacher, :garbage_collector # Same as above, just using explicit class references ORM.observers = Cacher, GarbageCollector https://github.com/rails/rails-observers/blob/master/lib/rails/observers/active_model/observing.rb#L19

Categories : Ruby On Rails

ruby on rails - Every syntax of rails create a new project
This is because, in your system there is rails 2 also installed and rails 2 is your default rails. The syntax for creating project in rails 2 is simply "rails project_name" that's why every time you are running **rails** either for generating controller, model or anything...the project is creating uninstall ruby and rails completely and follow this link to install rails in your system: How to install Ruby on Rails on linux OR https://www.digitalocean.com/community/articles/how-to-install-ruby-on-rails-on-ubuntu-12-04-lts-precise-pangolin-with-rvm Oh! I forgot to tell, you can install Ruby Version Manager (RVM) instead. may be this can help

Categories : Ruby On Rails

Block definition available throughout project without duplicate symbol error
Perhaps you defined the block in a .h file, so that it is defined in every .m file that imports this .h file? You have to declare it in a .h file: typedef NSComparisonResult(^UITagCompareBlock)(UIView*, UIView*); extern UITagCompareBlock uiTagCompareBlock; and define it in exactly one .m file: UITagCompareBlock uiTagCompareBlock = ^NSComparisonResult(UIView* a, UIView* b){ if (a.tag < b.tag) return NSOrderedAscending; else if (a.tag > b.tag) return NSOrderedDescending; else return NSOrderedSame; };

Categories : IOS

Why can't I use await keyword in my Windows Phone 7.1 MvvmCross project while using the Microsoft.Bcl - cannot await 'System.Threading.Tasks.Task?
You need to add the Microsoft.Bcl.Async NuGet package. These packages were previously unavailable on non-Microsoft platforms, but as part of the Xamarin collaboration Microsoft relicensed them to be usable under all platforms.

Categories : C#

I find a code block in chat.c a module of ppp project,but I can't understand it
Like the comment says, it's internal state the macros use to remember where they are and what they're doing. Nothing you need to worry about unless you are reimplementing the code, in which case the complete lack of documentation apart from that comment and the general coding style suggest you might have a problem. As it's static it is only accessible from that file (God help you if that code is from a header) and it has a lifetime the same as the executing program. But basically, you should not touch _O in your code.

Categories : C

Block helpers in rails
Roughly: def needs_clearance(level, &block) if current_user.clearance >= level capture(&block) end end Block helpers generally look like the following, e.g., to wrap something in a div: def box(&block) "<div class='box'>" + capture(&block) + "</div>" end From: http://timelessrepo.com/block-helpers-in-rails3 I'd consider reading that, too, as it discusses an interesting consequence of block helpers.

Categories : Ruby On Rails

How do I search a string for a keyword, then print whatever comes after that keyword in java?
You can use the indexOf method on the String, and then do substring for the characters after. int start = yourString.indexOf(searchString); System.out.println(yourString.subString(start + 1, start + 6);

Categories : Java

Nutch Keyword search cannot retrieve all the pages contain that keyword
I just solved the problem . Query query = Query.parse(searchQuery, conf); QueryParams queryParams = new QueryParams(); queryParams.setMaxHitsPerDup(100); queryParams.setNumHits(100); query.setParams(queryParams); Hits hits = bean.search(query); long allResultsCount =**hits.getTotal());** I changed this into long allResultsCount =**hits.getLength());**

Categories : Java

Rails 2 routes.rb: :except not working with block
I ended up just going to the index action of my pages controller and adding a raise ActionController::RoutingError.new('Not Found'). Goes one level deeper but the result is the same nonetheless.

Categories : Ruby On Rails



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.